summaryrefslogtreecommitdiff
path: root/stickynotes
diff options
context:
space:
mode:
authorQuintin Maldonado <[email protected]>2022-09-05 12:08:31 -0700
committerVictor Kareh <[email protected]>2026-06-03 18:06:56 -0400
commit1c9a5e6751f8f101d780955e48ea4532710d7068 (patch)
tree5fe3e25adf3052d1bef8074f5d283dc9da239fff /stickynotes
parentbdf674770c36b708cc1397b93f9fe44c6aef2c53 (diff)
downloadmate-applets-master.tar.bz2
mate-applets-master.tar.xz
stickynotes: add fixed-size notes supportHEADmaster
Add a new preference to force fixed size on all notes to prevent resizing. Also fix a bug where notes taller than the screen height would not display scrollbars after applet restart. Fixes #370
Diffstat (limited to 'stickynotes')
-rw-r--r--stickynotes/org.mate.stickynotes.gschema.xml.in5
-rw-r--r--stickynotes/sticky-notes-preferences.ui17
-rw-r--r--stickynotes/stickynotes.c45
-rw-r--r--stickynotes/stickynotes.h3
-rw-r--r--stickynotes/stickynotes_applet.c14
-rw-r--r--stickynotes/stickynotes_applet.h2
-rw-r--r--stickynotes/stickynotes_applet_callbacks.c14
-rw-r--r--stickynotes/stickynotes_callbacks.c3
8 files changed, 101 insertions, 2 deletions
diff --git a/stickynotes/org.mate.stickynotes.gschema.xml.in b/stickynotes/org.mate.stickynotes.gschema.xml.in
index c173f383..17eced67 100644
--- a/stickynotes/org.mate.stickynotes.gschema.xml.in
+++ b/stickynotes/org.mate.stickynotes.gschema.xml.in
@@ -70,5 +70,10 @@
<summary>Whether to hide all notes when click the icon</summary>
<description>If this option is disabled, the note is not hidden when the icon is clicked.</description>
</key>
+ <key name="fixed-size" type="b">
+ <default>false</default>
+ <summary>Whether to prevent note resizing on all notes</summary>
+ <description>If this option is enabled, resizing is restricted on all notes.</description>
+ </key>
</schema>
</schemalist>
diff --git a/stickynotes/sticky-notes-preferences.ui b/stickynotes/sticky-notes-preferences.ui
index 25ebfe33..8b916f44 100644
--- a/stickynotes/sticky-notes-preferences.ui
+++ b/stickynotes/sticky-notes-preferences.ui
@@ -390,6 +390,23 @@
<property name="width">2</property>
</packing>
</child>
+ <child>
+ <object class="GtkCheckButton" id="fixed_size_check">
+ <property name="label" translatable="yes">Force fixed size notes</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="tooltip_text" translatable="yes">Choose whether to restrict notes resizing</property>
+ <property name="halign">start</property>
+ <property name="use_underline">True</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">3</property>
+ <property name="width">2</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="expand">False</property>
diff --git a/stickynotes/stickynotes.c b/stickynotes/stickynotes.c
index e1e1f8cb..1a1422a4 100644
--- a/stickynotes/stickynotes.c
+++ b/stickynotes/stickynotes.c
@@ -86,7 +86,7 @@ static void
buffer_changed (GtkTextBuffer *buffer,
StickyNote *note)
{
- if ( (note->h + note->y) > stickynotes->max_height )
+ if ( (note->h + note->y) > stickynotes->max_height && (!note->force_fixed_size) )
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (note->w_scroller),
GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
@@ -201,6 +201,7 @@ stickynote_new_aux (GdkScreen *screen,
note->font_color = NULL;
note->font = NULL;
note->locked = FALSE;
+ note->force_fixed_size = FALSE;
note->x = x;
note->y = y;
note->w = w;
@@ -256,6 +257,8 @@ stickynote_new_aux (GdkScreen *screen,
stickynote_set_font (note, NULL, TRUE);
stickynote_set_locked (note, FALSE);
+ stickynote_set_fixed_size (note, stickynotes->force_fixed_size);
+
gtk_widget_realize (note->w_window);
/* Connect a popup menu to all buttons and title */
@@ -763,6 +766,46 @@ stickynote_set_visible (StickyNote *note,
}
}
+/* Set forced fixed size */
+void stickynote_set_fixed_size (StickyNote *note,
+ gboolean force_fixed_size)
+{
+ note->force_fixed_size = force_fixed_size;
+
+ if (force_fixed_size) {
+ gint w, h;
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (note->w_scroller),
+ GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+ gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (note->w_body),
+ GTK_WRAP_CHAR);
+ gtk_widget_set_visible (note->w_resize_se, FALSE);
+ gtk_widget_set_visible (note->w_resize_sw, FALSE);
+ if (note->w == 0 && note->h == 0) {
+ w = g_settings_get_int (stickynotes->settings, "default-width");
+ h = g_settings_get_int (stickynotes->settings, "default-height");
+ }
+ else {
+ w = note->w;
+ h = note->h;
+ }
+ gtk_window_set_default_size (GTK_WINDOW (note->w_window), w, h);
+ gtk_window_resize (GTK_WINDOW (note->w_window), w, h);
+ gtk_window_set_resizable (GTK_WINDOW (note->w_window), FALSE);
+ }
+ else {
+ GtkPolicyType vscroll_pol = GTK_POLICY_NEVER;
+ if ((note->h + note->y) > stickynotes->max_height)
+ vscroll_pol = GTK_POLICY_AUTOMATIC;
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (note->w_scroller),
+ GTK_POLICY_NEVER, vscroll_pol);
+ gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (note->w_body),
+ GTK_WRAP_WORD);
+ gtk_widget_set_visible (note->w_resize_se, TRUE);
+ gtk_widget_set_visible (note->w_resize_sw, TRUE);
+ gtk_window_set_resizable (GTK_WINDOW (note->w_window), TRUE);
+ }
+}
+
/* Add a sticky note */
void
stickynotes_add (GdkScreen *screen)
diff --git a/stickynotes/stickynotes.h b/stickynotes/stickynotes.h
index 5f42abfa..151bf10e 100644
--- a/stickynotes/stickynotes.h
+++ b/stickynotes/stickynotes.h
@@ -61,6 +61,7 @@ typedef struct
gchar *font_color; /* Font color */
gchar *font; /* Note font */
gboolean locked; /* Note locked state */
+ gboolean force_fixed_size; /* Note resizing is restricted */
gint x; /* Note x-coordinate */
gint y; /* Note y-coordinate */
@@ -89,6 +90,8 @@ void stickynote_set_locked (StickyNote *note,
gboolean locked);
void stickynote_set_visible (StickyNote *note,
gboolean visible);
+void stickynote_set_fixed_size (StickyNote *note,
+ gboolean force_fixed_size);
void stickynote_change_properties (StickyNote *note);
diff --git a/stickynotes/stickynotes_applet.c b/stickynotes/stickynotes_applet.c
index 0fb9b6a9..fa777efe 100644
--- a/stickynotes/stickynotes_applet.c
+++ b/stickynotes/stickynotes_applet.c
@@ -283,6 +283,9 @@ stickynotes_applet_init_prefs (void)
stickynotes->w_prefs_desktop =
GTK_WIDGET (&GTK_CHECK_BUTTON (gtk_builder_get_object (stickynotes->builder,
"desktop_hide_check"))->toggle_button);
+ stickynotes->w_prefs_fixed_size =
+ GTK_WIDGET (&GTK_CHECK_BUTTON (gtk_builder_get_object (stickynotes->builder,
+ "fixed_size_check"))->toggle_button);
g_signal_connect (stickynotes->w_prefs, "response",
G_CALLBACK (preferences_response_cb), NULL);
@@ -308,6 +311,8 @@ stickynotes_applet_init_prefs (void)
G_CALLBACK (preferences_save_cb), NULL);
g_signal_connect_swapped (stickynotes->w_prefs_desktop, "toggled",
G_CALLBACK (preferences_save_cb), NULL);
+ g_signal_connect_swapped (stickynotes->w_prefs_fixed_size, "toggled",
+ G_CALLBACK (preferences_save_cb), NULL);
{
GtkSizeGroup *group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
@@ -367,6 +372,8 @@ stickynotes_applet_init_prefs (void)
gtk_widget_set_sensitive (stickynotes->w_prefs_sticky, FALSE);
if (!g_settings_is_writable (stickynotes->settings, "force-default"))
gtk_widget_set_sensitive (stickynotes->w_prefs_force, FALSE);
+ if (!g_settings_is_writable (stickynotes->settings, "fixed-size"))
+ gtk_widget_set_sensitive (stickynotes->w_prefs_fixed_size, FALSE);
stickynotes_applet_update_prefs ();
}
@@ -489,7 +496,7 @@ void
stickynotes_applet_update_prefs (void)
{
gint width, height;
- gboolean sys_color, sys_font, sticky, force_default, desktop_hide;
+ gboolean sys_color, sys_font, sticky, force_default, desktop_hide, fixed_size;
char *font_str;
char *color_str, *font_color_str;
GdkRGBA color, font_color;
@@ -511,6 +518,8 @@ stickynotes_applet_update_prefs (void)
"force-default");
desktop_hide = g_settings_get_boolean (stickynotes->settings,
"desktop-hide");
+ fixed_size = g_settings_get_boolean (stickynotes->settings,
+ "fixed-size");
font_str = g_settings_get_string (stickynotes->settings,
"default-font");
@@ -545,6 +554,9 @@ stickynotes_applet_update_prefs (void)
force_default);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (stickynotes->w_prefs_desktop),
desktop_hide);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (stickynotes->w_prefs_fixed_size),
+ fixed_size);
+ stickynotes->force_fixed_size = fixed_size;
gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (stickynotes->w_prefs_color),
&color);
diff --git a/stickynotes/stickynotes_applet.h b/stickynotes/stickynotes_applet.h
index 072318d3..e14f076f 100644
--- a/stickynotes/stickynotes_applet.h
+++ b/stickynotes/stickynotes_applet.h
@@ -50,6 +50,7 @@ typedef struct
GtkWidget *w_prefs_sticky;
GtkWidget *w_prefs_force;
GtkWidget *w_prefs_desktop;
+ GtkWidget *w_prefs_fixed_size;
GList *notes; /* Linked-List of all the sticky notes */
GList *applets; /* Linked-List of all the applets */
@@ -63,6 +64,7 @@ typedef struct
guint last_timeout_data;
gboolean visible; /* Toggle show/hide notes */
+ gboolean force_fixed_size; /* Force fixed size notes */
} StickyNotes;
/* Sticky Notes Applet */
diff --git a/stickynotes/stickynotes_applet_callbacks.c b/stickynotes/stickynotes_applet_callbacks.c
index 69869a26..4be36f0f 100644
--- a/stickynotes/stickynotes_applet_callbacks.c
+++ b/stickynotes/stickynotes_applet_callbacks.c
@@ -478,6 +478,7 @@ preferences_save_cb (gpointer data)
gboolean sticky;
gboolean force_default;
gboolean desktop_hide;
+ gboolean fixed_size;
gdouble adjustment_value;
adjustment_value = gtk_adjustment_get_value (stickynotes->w_prefs_width);
@@ -491,6 +492,7 @@ preferences_save_cb (gpointer data)
sticky = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (stickynotes->w_prefs_sticky));
force_default = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (stickynotes->w_prefs_force));
desktop_hide = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (stickynotes->w_prefs_desktop));
+ fixed_size = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (stickynotes->w_prefs_fixed_size));
if (g_settings_is_writable (stickynotes->settings,
"default-width"))
@@ -520,6 +522,10 @@ preferences_save_cb (gpointer data)
"desktop-hide"))
g_settings_set_boolean (stickynotes->settings,
"desktop-hide", desktop_hide);
+ if (g_settings_is_writable (stickynotes->settings,
+ "fixed-size"))
+ g_settings_set_boolean (stickynotes->settings,
+ "fixed-size", fixed_size);
}
/* Preferences Callback : Change color. */
@@ -626,6 +632,14 @@ preferences_apply_cb (GSettings *settings,
}
}
+ else if (!strcmp (key, "fixed-size")) {
+ gboolean fixed = g_settings_get_boolean (settings, "fixed-size");
+ for (l = stickynotes->notes; l; l = l->next) {
+ note = l->data;
+ stickynote_set_fixed_size (note, fixed);
+ }
+ }
+
stickynotes_applet_update_prefs ();
stickynotes_applet_update_menus ();
}
diff --git a/stickynotes/stickynotes_callbacks.c b/stickynotes/stickynotes_callbacks.c
index 3f22dab7..58fb53ca 100644
--- a/stickynotes/stickynotes_callbacks.c
+++ b/stickynotes/stickynotes_callbacks.c
@@ -45,6 +45,9 @@ gboolean stickynote_resize_cb (GtkWidget *widget,
GdkEventButton *event,
StickyNote *note)
{
+ if (note->force_fixed_size)
+ return FALSE;
+
if (event->type == GDK_BUTTON_PRESS && event->button == 1) {
if (widget == note->w_resize_se)
gtk_window_begin_resize_drag (GTK_WINDOW (note->w_window),