summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorraveit65 <[email protected]>2020-12-27 11:46:13 +0100
committerGitHub <[email protected]>2020-12-27 11:46:13 +0100
commit181184aba23ac392a7a6ce92751ab5561721f3c2 (patch)
treef8d06ef68f64428f2b4cba8d273c0744b2ac751f
parenteddd0898e16124081e226b07fd0901ff0eae2871 (diff)
downloadmate-applets-181184aba23ac392a7a6ce92751ab5561721f3c2.tar.bz2
mate-applets-181184aba23ac392a7a6ce92751ab5561721f3c2.tar.xz
stickynotes: improve code-style
- tabs to spaces - shortened lines - unnecessary casts on functions which accept a gpointer like g_signal_connect
-rw-r--r--stickynotes/stickynotes.c1816
-rw-r--r--stickynotes/stickynotes.h123
-rw-r--r--stickynotes/stickynotes_applet.c1013
-rw-r--r--stickynotes/stickynotes_applet.h112
-rw-r--r--stickynotes/stickynotes_applet_callbacks.c840
-rw-r--r--stickynotes/stickynotes_applet_callbacks.h99
-rw-r--r--stickynotes/stickynotes_callbacks.c212
-rw-r--r--stickynotes/stickynotes_callbacks.h70
-rw-r--r--stickynotes/util.c153
-rw-r--r--stickynotes/util.h6
10 files changed, 2380 insertions, 2064 deletions
diff --git a/stickynotes/stickynotes.c b/stickynotes/stickynotes.c
index 0b163dc0..b22f1aa9 100644
--- a/stickynotes/stickynotes.c
+++ b/stickynotes/stickynotes.c
@@ -50,978 +50,1050 @@ set_icon_geometry (GdkWindow *window,
int width,
int height)
{
- gulong data[4];
- Display *dpy;
-
- dpy = gdk_x11_display_get_xdisplay (gdk_window_get_display (window));
-
- data[0] = x;
- data[1] = y;
- data[2] = width;
- data[3] = height;
-
- XChangeProperty (dpy,
- GDK_WINDOW_XID (window),
- gdk_x11_get_xatom_by_name_for_display (
- gdk_window_get_display (window),
- "_NET_WM_ICON_GEOMETRY"),
- XA_CARDINAL, 32, PropModeReplace,
- (guchar *)&data, 4);
+ gulong data[4];
+ Display *dpy;
+
+ dpy = gdk_x11_display_get_xdisplay (gdk_window_get_display (window));
+
+ data[0] = x;
+ data[1] = y;
+ data[2] = width;
+ data[3] = height;
+
+ XChangeProperty (dpy,
+ GDK_WINDOW_XID (window),
+ gdk_x11_get_xatom_by_name_for_display (
+ gdk_window_get_display (window),
+ "_NET_WM_ICON_GEOMETRY"),
+ XA_CARDINAL, 32, PropModeReplace,
+ (guchar *)&data, 4);
}
/* Called when a timeout occurs. */
static gboolean
timeout_happened (gpointer data)
{
- if (GPOINTER_TO_UINT (data) == stickynotes->last_timeout_data)
- stickynotes_save ();
- return FALSE;
+ if (GPOINTER_TO_UINT (data) == stickynotes->last_timeout_data)
+ stickynotes_save ();
+
+ return FALSE;
}
/* Called when a text buffer is changed. */
static void
-buffer_changed (GtkTextBuffer *buffer, StickyNote *note)
+buffer_changed (GtkTextBuffer *buffer,
+ StickyNote *note)
{
- if ( (note->h + note->y) > stickynotes->max_height )
- gtk_scrolled_window_set_policy ( GTK_SCROLLED_WINDOW(note->w_scroller),
- GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
-
- /* When a buffer is changed, we set a 10 second timer. When
- the timer triggers, we will save the buffer if there have
- been no subsequent changes. */
- ++stickynotes->last_timeout_data;
- g_timeout_add_seconds (10, (GSourceFunc) timeout_happened,
- GUINT_TO_POINTER (stickynotes->last_timeout_data));
+ if ( (note->h + note->y) > stickynotes->max_height )
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (note->w_scroller),
+ GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
+
+ /* When a buffer is changed, we set a 10 second timer. When
+ the timer triggers, we will save the buffer if there have
+ been no subsequent changes. */
+ ++stickynotes->last_timeout_data;
+ g_timeout_add_seconds (10, (GSourceFunc) timeout_happened,
+ GUINT_TO_POINTER (stickynotes->last_timeout_data));
}
/* Create a new (empty) Sticky Note at a specific position
and with specific size */
static StickyNote *
-stickynote_new_aux (GdkScreen *screen, gint x, gint y, gint w, gint h)
+stickynote_new_aux (GdkScreen *screen,
+ gint x,
+ gint y,
+ gint w,
+ gint h)
{
- StickyNote *note;
- GtkBuilder *builder;
-
- note = g_new (StickyNote, 1);
-
- builder = gtk_builder_new ();
- gtk_builder_add_from_resource (builder, GRESOURCE "sticky-notes-note.ui", NULL);
- gtk_builder_add_from_resource (builder, GRESOURCE "sticky-notes-properties.ui", NULL);
-
- note->w_window = GTK_WIDGET (gtk_builder_get_object (builder, "stickynote_window"));
- gtk_window_set_screen(GTK_WINDOW(note->w_window),screen);
- gtk_window_set_decorated (GTK_WINDOW (note->w_window), FALSE);
- gtk_window_set_skip_taskbar_hint (GTK_WINDOW (note->w_window), TRUE);
- gtk_window_set_skip_pager_hint (GTK_WINDOW (note->w_window), TRUE);
- gtk_widget_add_events (note->w_window, GDK_BUTTON_PRESS_MASK);
-
- note->w_title = GTK_WIDGET (gtk_builder_get_object (builder, "title_label"));
- note->w_body = GTK_WIDGET (gtk_builder_get_object (builder, "body_text"));
- note->w_scroller = GTK_WIDGET (gtk_builder_get_object (builder, "body_scroller"));
- note->w_lock = GTK_WIDGET (gtk_builder_get_object (builder, "lock_button"));
- gtk_widget_add_events (note->w_lock, GDK_BUTTON_PRESS_MASK);
-
- note->buffer = GTK_SOURCE_BUFFER(gtk_text_view_get_buffer(GTK_TEXT_VIEW(note->w_body)));
-
- note->w_close = GTK_WIDGET (gtk_builder_get_object (builder, "close_button"));
- gtk_widget_add_events (note->w_close, GDK_BUTTON_PRESS_MASK);
- note->w_resize_se = GTK_WIDGET (gtk_builder_get_object (builder, "resize_se_box"));
- gtk_widget_add_events (note->w_resize_se, GDK_BUTTON_PRESS_MASK);
- note->w_resize_sw = GTK_WIDGET (gtk_builder_get_object (builder, "resize_sw_box"));
- gtk_widget_add_events (note->w_resize_sw, GDK_BUTTON_PRESS_MASK);
-
- note->img_lock = GTK_IMAGE (gtk_builder_get_object (builder,
- "lock_img"));
- note->img_close = GTK_IMAGE (gtk_builder_get_object (builder,
- "close_img"));
- note->img_resize_se = GTK_IMAGE (gtk_builder_get_object (builder,
- "resize_se_img"));
- note->img_resize_sw = GTK_IMAGE (gtk_builder_get_object (builder,
- "resize_sw_img"));
-
- /* deal with RTL environments */
- gtk_widget_set_direction (GTK_WIDGET (gtk_builder_get_object (builder, "resize_bar")),
- GTK_TEXT_DIR_LTR);
-
- note->w_menu = GTK_WIDGET (gtk_builder_get_object (builder, "stickynote_menu"));
- note->ta_lock_toggle_item = GTK_TOGGLE_ACTION (gtk_builder_get_object (builder,
- "popup_toggle_lock"));
-
- note->w_properties = GTK_WIDGET (gtk_builder_get_object (builder,
- "stickynote_properties"));
- gtk_window_set_screen (GTK_WINDOW (note->w_properties), screen);
-
- note->w_entry = GTK_WIDGET (gtk_builder_get_object (builder, "title_entry"));
- note->w_color = GTK_WIDGET (gtk_builder_get_object (builder, "note_color"));
- note->w_color_label = GTK_WIDGET (gtk_builder_get_object (builder, "color_label"));
- note->w_font_color = GTK_WIDGET (gtk_builder_get_object (builder, "font_color"));
- note->w_font_color_label = GTK_WIDGET (gtk_builder_get_object (builder,
- "font_color_label"));
- note->w_font = GTK_WIDGET (gtk_builder_get_object (builder, "note_font"));
- note->w_font_label = GTK_WIDGET (gtk_builder_get_object (builder, "font_label"));
- note->w_def_color = GTK_WIDGET (&GTK_CHECK_BUTTON (
- gtk_builder_get_object (builder,
- "def_color_check"))->toggle_button);
- note->w_def_font = GTK_WIDGET (&GTK_CHECK_BUTTON (
- gtk_builder_get_object (builder,
- "def_font_check"))->toggle_button);
-
- note->color = NULL;
- note->font_color = NULL;
- note->font = NULL;
- note->locked = FALSE;
- note->x = x;
- note->y = y;
- note->w = w;
- note->h = h;
-
- /* Customize the window */
- if (g_settings_get_boolean (stickynotes->settings, "sticky"))
- gtk_window_stick(GTK_WINDOW(note->w_window));
-
- if (w == 0 || h == 0)
- gtk_window_resize (GTK_WINDOW(note->w_window),
- g_settings_get_int (stickynotes->settings, "default-width"),
- g_settings_get_int (stickynotes->settings, "default-height"));
- else
- gtk_window_resize (GTK_WINDOW(note->w_window),
- note->w,
- note->h);
-
- if (x != -1 && y != -1)
- gtk_window_move (GTK_WINDOW(note->w_window),
- note->x,
- note->y);
-
- /* Set the button images */
- gtk_image_set_from_icon_name (note->img_close, STICKYNOTES_STOCK_CLOSE, GTK_ICON_SIZE_MENU);
- gtk_image_set_pixel_size (note->img_close, STICKYNOTES_ICON_SIZE);
-
- gtk_image_set_from_icon_name (note->img_resize_se, STICKYNOTES_STOCK_RESIZE_SE, GTK_ICON_SIZE_MENU);
- gtk_image_set_pixel_size (note->img_resize_se, STICKYNOTES_ICON_SIZE);
-
- gtk_image_set_from_icon_name (note->img_resize_sw, STICKYNOTES_STOCK_RESIZE_SW, GTK_ICON_SIZE_MENU);
- gtk_image_set_pixel_size (note->img_resize_sw, STICKYNOTES_ICON_SIZE);
-
- gtk_widget_show(note->w_lock);
- gtk_widget_show(note->w_close);
- gtk_widget_show(GTK_WIDGET (gtk_builder_get_object (builder, "resize_bar")));
-
- /* Customize the title and colors, hide and unlock */
- stickynote_set_title(note, NULL);
- stickynote_set_color(note, NULL, NULL, TRUE);
- stickynote_set_font(note, NULL, TRUE);
- stickynote_set_locked(note, FALSE);
-
- gtk_widget_realize (note->w_window);
-
- /* Connect a popup menu to all buttons and title */
- /* GtkBuilder holds and drops the references to all the widgets it
- * creates for as long as it exist (GtkBuilder). Hence in our callback
- * we would have an invalid GtkMenu. We need to ref it.
- */
- g_object_ref (note->w_menu);
- g_signal_connect (G_OBJECT (note->w_window), "button-press-event",
- G_CALLBACK (stickynote_show_popup_menu), note->w_menu);
-
- g_signal_connect (G_OBJECT (note->w_lock), "button-press-event",
- G_CALLBACK (stickynote_show_popup_menu), note->w_menu);
-
- g_signal_connect (G_OBJECT (note->w_close), "button-press-event",
- G_CALLBACK (stickynote_show_popup_menu), note->w_menu);
-
- g_signal_connect (G_OBJECT (note->w_resize_se), "button-press-event",
- G_CALLBACK (stickynote_show_popup_menu), note->w_menu);
-
- g_signal_connect (G_OBJECT (note->w_resize_sw), "button-press-event",
- G_CALLBACK (stickynote_show_popup_menu), note->w_menu);
-
- /* Connect a properties dialog to the note */
- gtk_window_set_transient_for (GTK_WINDOW(note->w_properties),
- GTK_WINDOW(note->w_window));
- gtk_dialog_set_default_response (GTK_DIALOG(note->w_properties),
- GTK_RESPONSE_CLOSE);
- g_signal_connect (G_OBJECT (note->w_properties), "response",
- G_CALLBACK (response_cb), note);
-
- /* Connect signals to the sticky note */
- g_signal_connect (G_OBJECT (note->w_lock), "clicked",
- G_CALLBACK (stickynote_toggle_lock_cb), note);
- g_signal_connect (G_OBJECT (note->w_close), "clicked",
- G_CALLBACK (stickynote_close_cb), note);
- g_signal_connect (G_OBJECT (note->w_resize_se), "button-press-event",
- G_CALLBACK (stickynote_resize_cb), note);
- g_signal_connect (G_OBJECT (note->w_resize_sw), "button-press-event",
- G_CALLBACK (stickynote_resize_cb), note);
-
- g_signal_connect (G_OBJECT (note->w_window), "button-press-event",
- G_CALLBACK (stickynote_move_cb), note);
- g_signal_connect (G_OBJECT (note->w_window), "configure-event",
- G_CALLBACK (stickynote_configure_cb), note);
- g_signal_connect (G_OBJECT (note->w_window), "delete-event",
- G_CALLBACK (stickynote_delete_cb), note);
-
- g_signal_connect (gtk_builder_get_object (builder,
- "popup_create"), "activate",
- G_CALLBACK (popup_create_cb), note);
- g_signal_connect (gtk_builder_get_object (builder,
- "popup_destroy"), "activate",
- G_CALLBACK (popup_destroy_cb), note);
- g_signal_connect (gtk_builder_get_object (builder,
- "popup_toggle_lock"), "toggled",
- G_CALLBACK (popup_toggle_lock_cb), note);
- g_signal_connect (gtk_builder_get_object (builder,
- "popup_properties"), "activate",
- G_CALLBACK (popup_properties_cb), note);
-
- g_signal_connect_swapped (G_OBJECT (note->w_entry), "changed",
- G_CALLBACK (properties_apply_title_cb), note);
- g_signal_connect (G_OBJECT (note->w_color), "color-set",
- G_CALLBACK (properties_color_cb), note);
- g_signal_connect (G_OBJECT (note->w_font_color), "color-set",
- G_CALLBACK (properties_color_cb), note);
- g_signal_connect_swapped (G_OBJECT (note->w_def_color), "toggled",
- G_CALLBACK (properties_apply_color_cb), note);
- g_signal_connect (G_OBJECT (note->w_font), "font-set",
- G_CALLBACK (properties_font_cb), note);
- g_signal_connect_swapped (G_OBJECT (note->w_def_font), "toggled",
- G_CALLBACK (properties_apply_font_cb), note);
- g_signal_connect (G_OBJECT (note->w_entry), "activate",
- G_CALLBACK (properties_activate_cb), note);
- g_signal_connect (G_OBJECT (note->w_properties), "delete-event",
- G_CALLBACK (gtk_widget_hide), note);
-
- g_object_unref(builder);
-
- g_signal_connect_after (note->w_body, "button-press-event",
- G_CALLBACK (gtk_true), note);
-
- g_signal_connect (gtk_text_view_get_buffer(GTK_TEXT_VIEW(note->w_body)),
- "changed",
- G_CALLBACK (buffer_changed), note);
-
- return note;
+ StickyNote *note;
+ GtkBuilder *builder;
+
+ note = g_new (StickyNote, 1);
+
+ builder = gtk_builder_new ();
+ gtk_builder_add_from_resource (builder,
+ GRESOURCE "sticky-notes-note.ui",
+ NULL);
+ gtk_builder_add_from_resource (builder,
+ GRESOURCE "sticky-notes-properties.ui",
+ NULL);
+
+ note->w_window = GTK_WIDGET (gtk_builder_get_object (builder,
+ "stickynote_window"));
+ gtk_window_set_screen (GTK_WINDOW (note->w_window),screen);
+ gtk_window_set_decorated (GTK_WINDOW (note->w_window), FALSE);
+ gtk_window_set_skip_taskbar_hint (GTK_WINDOW (note->w_window), TRUE);
+ gtk_window_set_skip_pager_hint (GTK_WINDOW (note->w_window), TRUE);
+ gtk_widget_add_events (note->w_window, GDK_BUTTON_PRESS_MASK);
+
+ note->w_title = GTK_WIDGET (gtk_builder_get_object (builder,
+ "title_label"));
+ note->w_body = GTK_WIDGET (gtk_builder_get_object (builder,
+ "body_text"));
+ note->w_scroller = GTK_WIDGET (gtk_builder_get_object (builder,
+ "body_scroller"));
+ note->w_lock = GTK_WIDGET (gtk_builder_get_object (builder,
+ "lock_button"));
+ gtk_widget_add_events (note->w_lock, GDK_BUTTON_PRESS_MASK);
+
+ note->buffer =
+ GTK_SOURCE_BUFFER (gtk_text_view_get_buffer (GTK_TEXT_VIEW (note->w_body)));
+
+ note->w_close =
+ GTK_WIDGET (gtk_builder_get_object (builder, "close_button"));
+ gtk_widget_add_events (note->w_close, GDK_BUTTON_PRESS_MASK);
+ note->w_resize_se =
+ GTK_WIDGET (gtk_builder_get_object (builder, "resize_se_box"));
+ gtk_widget_add_events (note->w_resize_se, GDK_BUTTON_PRESS_MASK);
+ note->w_resize_sw =
+ GTK_WIDGET (gtk_builder_get_object (builder, "resize_sw_box"));
+ gtk_widget_add_events (note->w_resize_sw, GDK_BUTTON_PRESS_MASK);
+
+ note->img_lock =
+ GTK_IMAGE (gtk_builder_get_object (builder, "lock_img"));
+ note->img_close =
+ GTK_IMAGE (gtk_builder_get_object (builder, "close_img"));
+ note->img_resize_se =
+ GTK_IMAGE (gtk_builder_get_object (builder, "resize_se_img"));
+ note->img_resize_sw =
+ GTK_IMAGE (gtk_builder_get_object (builder, "resize_sw_img"));
+
+ /* deal with RTL environments */
+ gtk_widget_set_direction (GTK_WIDGET (gtk_builder_get_object (builder, "resize_bar")),
+ GTK_TEXT_DIR_LTR);
+
+ note->w_menu = GTK_WIDGET (gtk_builder_get_object (builder,
+ "stickynote_menu"));
+ note->ta_lock_toggle_item =
+ GTK_TOGGLE_ACTION (gtk_builder_get_object (builder,
+ "popup_toggle_lock"));
+
+ note->w_properties =
+ GTK_WIDGET (gtk_builder_get_object (builder,
+ "stickynote_properties"));
+ gtk_window_set_screen (GTK_WINDOW (note->w_properties), screen);
+
+ note->w_entry =
+ GTK_WIDGET (gtk_builder_get_object (builder, "title_entry"));
+ note->w_color =
+ GTK_WIDGET (gtk_builder_get_object (builder, "note_color"));
+ note->w_color_label =
+ GTK_WIDGET (gtk_builder_get_object (builder, "color_label"));
+ note->w_font_color =
+ GTK_WIDGET (gtk_builder_get_object (builder, "font_color"));
+ note->w_font_color_label =
+ GTK_WIDGET (gtk_builder_get_object (builder,
+ "font_color_label"));
+ note->w_font =
+ GTK_WIDGET (gtk_builder_get_object (builder, "note_font"));
+ note->w_font_label =
+ GTK_WIDGET (gtk_builder_get_object (builder, "font_label"));
+ note->w_def_color =
+ GTK_WIDGET (&GTK_CHECK_BUTTON (gtk_builder_get_object (builder,
+ "def_color_check"))->toggle_button);
+ note->w_def_font =
+ GTK_WIDGET (&GTK_CHECK_BUTTON (gtk_builder_get_object (builder,
+ "def_font_check"))->toggle_button);
+
+ note->color = NULL;
+ note->font_color = NULL;
+ note->font = NULL;
+ note->locked = FALSE;
+ note->x = x;
+ note->y = y;
+ note->w = w;
+ note->h = h;
+
+ /* Customize the window */
+ if (g_settings_get_boolean (stickynotes->settings, "sticky"))
+ gtk_window_stick (GTK_WINDOW (note->w_window));
+
+ if (w == 0 || h == 0)
+ gtk_window_resize (GTK_WINDOW (note->w_window),
+ g_settings_get_int (stickynotes->settings,
+ "default-width"),
+ g_settings_get_int (stickynotes->settings,
+ "default-height"));
+ else
+ gtk_window_resize (GTK_WINDOW (note->w_window),
+ note->w,
+ note->h);
+
+ if (x != -1 && y != -1)
+ gtk_window_move (GTK_WINDOW (note->w_window),
+ note->x,
+ note->y);
+
+ /* Set the button images */
+ gtk_image_set_from_icon_name (note->img_close,
+ STICKYNOTES_STOCK_CLOSE,
+ GTK_ICON_SIZE_MENU);
+ gtk_image_set_pixel_size (note->img_close,
+ STICKYNOTES_ICON_SIZE);
+
+ gtk_image_set_from_icon_name (note->img_resize_se,
+ STICKYNOTES_STOCK_RESIZE_SE,
+ GTK_ICON_SIZE_MENU);
+ gtk_image_set_pixel_size (note->img_resize_se,
+ STICKYNOTES_ICON_SIZE);
+
+ gtk_image_set_from_icon_name (note->img_resize_sw,
+ STICKYNOTES_STOCK_RESIZE_SW,
+ GTK_ICON_SIZE_MENU);
+ gtk_image_set_pixel_size (note->img_resize_sw,
+ STICKYNOTES_ICON_SIZE);
+
+ gtk_widget_show (note->w_lock);
+ gtk_widget_show (note->w_close);
+ gtk_widget_show (GTK_WIDGET (gtk_builder_get_object (builder,
+ "resize_bar")));
+
+ /* Customize the title and colors, hide and unlock */
+ stickynote_set_title (note, NULL);
+ stickynote_set_color (note, NULL, NULL, TRUE);
+ stickynote_set_font (note, NULL, TRUE);
+ stickynote_set_locked (note, FALSE);
+
+ gtk_widget_realize (note->w_window);
+
+ /* Connect a popup menu to all buttons and title */
+ /* GtkBuilder holds and drops the references to all the widgets it
+ * creates for as long as it exist (GtkBuilder). Hence in our callback
+ * we would have an invalid GtkMenu. We need to ref it.
+ */
+ g_object_ref (note->w_menu);
+ g_signal_connect (G_OBJECT (note->w_window), "button-press-event",
+ G_CALLBACK (stickynote_show_popup_menu), note->w_menu);
+
+ g_signal_connect (G_OBJECT (note->w_lock), "button-press-event",
+ G_CALLBACK (stickynote_show_popup_menu), note->w_menu);
+
+ g_signal_connect (G_OBJECT (note->w_close), "button-press-event",
+ G_CALLBACK (stickynote_show_popup_menu), note->w_menu);
+
+ g_signal_connect (G_OBJECT (note->w_resize_se), "button-press-event",
+ G_CALLBACK (stickynote_show_popup_menu), note->w_menu);
+
+ g_signal_connect (G_OBJECT (note->w_resize_sw), "button-press-event",
+ G_CALLBACK (stickynote_show_popup_menu), note->w_menu);
+
+ /* Connect a properties dialog to the note */
+ gtk_window_set_transient_for (GTK_WINDOW (note->w_properties),
+ GTK_WINDOW (note->w_window));
+ gtk_dialog_set_default_response (GTK_DIALOG (note->w_properties),
+ GTK_RESPONSE_CLOSE);
+ g_signal_connect (G_OBJECT (note->w_properties), "response",
+ G_CALLBACK (response_cb), note);
+
+ /* Connect signals to the sticky note */
+ g_signal_connect (G_OBJECT (note->w_lock), "clicked",
+ G_CALLBACK (stickynote_toggle_lock_cb), note);
+ g_signal_connect (G_OBJECT (note->w_close), "clicked",
+ G_CALLBACK (stickynote_close_cb), note);
+ g_signal_connect (G_OBJECT (note->w_resize_se), "button-press-event",
+ G_CALLBACK (stickynote_resize_cb), note);
+ g_signal_connect (G_OBJECT (note->w_resize_sw), "button-press-event",
+ G_CALLBACK (stickynote_resize_cb), note);
+
+ g_signal_connect (G_OBJECT (note->w_window), "button-press-event",
+ G_CALLBACK (stickynote_move_cb), note);
+ g_signal_connect (G_OBJECT (note->w_window), "configure-event",
+ G_CALLBACK (stickynote_configure_cb), note);
+ g_signal_connect (G_OBJECT (note->w_window), "delete-event",
+ G_CALLBACK (stickynote_delete_cb), note);
+
+ g_signal_connect (gtk_builder_get_object (builder, "popup_create"),
+ "activate", G_CALLBACK (popup_create_cb), note);
+ g_signal_connect (gtk_builder_get_object (builder, "popup_destroy"),
+ "activate", G_CALLBACK (popup_destroy_cb), note);
+ g_signal_connect (gtk_builder_get_object (builder, "popup_toggle_lock"),
+ "toggled", G_CALLBACK (popup_toggle_lock_cb), note);
+ g_signal_connect (gtk_builder_get_object (builder, "popup_properties"),
+ "activate", G_CALLBACK (popup_properties_cb), note);
+
+ g_signal_connect_swapped (G_OBJECT (note->w_entry), "changed",
+ G_CALLBACK (properties_apply_title_cb), note);
+ g_signal_connect (G_OBJECT (note->w_color), "color-set",
+ G_CALLBACK (properties_color_cb), note);
+ g_signal_connect (G_OBJECT (note->w_font_color), "color-set",
+ G_CALLBACK (properties_color_cb), note);
+ g_signal_connect_swapped (G_OBJECT (note->w_def_color), "toggled",
+ G_CALLBACK (properties_apply_color_cb), note);
+ g_signal_connect (G_OBJECT (note->w_font), "font-set",
+ G_CALLBACK (properties_font_cb), note);
+ g_signal_connect_swapped (G_OBJECT (note->w_def_font), "toggled",
+ G_CALLBACK (properties_apply_font_cb), note);
+ g_signal_connect (G_OBJECT (note->w_entry), "activate",
+ G_CALLBACK (properties_activate_cb), note);
+ g_signal_connect (G_OBJECT (note->w_properties), "delete-event",
+ G_CALLBACK (gtk_widget_hide), note);
+
+ g_object_unref (builder);
+
+ g_signal_connect_after (note->w_body, "button-press-event",
+ G_CALLBACK (gtk_true), note);
+
+ g_signal_connect (gtk_text_view_get_buffer (GTK_TEXT_VIEW (note->w_body)),
+ "changed", G_CALLBACK (buffer_changed), note);
+
+ return note;
}
/* Create a new (empty) Sticky Note */
StickyNote *
stickynote_new (GdkScreen *screen)
{
- return stickynote_new_aux (screen, -1, -1, 0, 0);
+ return stickynote_new_aux (screen, -1, -1, 0, 0);
}
/* Destroy a Sticky Note */
-void stickynote_free(StickyNote *note)
+void stickynote_free (StickyNote *note)
{
- gtk_widget_destroy(note->w_properties);
- gtk_widget_destroy(note->w_menu);
- gtk_widget_destroy(note->w_window);
+ gtk_widget_destroy (note->w_properties);
+ gtk_widget_destroy (note->w_menu);
+ gtk_widget_destroy (note->w_window);
- g_free(note->color);
- g_free(note->font_color);
- g_free(note->font);
+ g_free (note->color);
+ g_free (note->font_color);
+ g_free (note->font);
- g_free(note);
+ g_free (note);
}
/* Change the sticky note title and color */
void stickynote_change_properties (StickyNote *note)
{
- char *color_str = NULL;
-
- gtk_entry_set_text(GTK_ENTRY(note->w_entry),
- gtk_label_get_text (GTK_LABEL (note->w_title)));
-
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(note->w_def_color),
- note->color == NULL);
-
- if (note->color)
- color_str = g_strdup (note->color);
- else
- {
- color_str = g_settings_get_string (stickynotes->settings, "default-color");
- }
-
- if (color_str)
- {
- GdkRGBA color;
- gdk_rgba_parse (&color, color_str);
- gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (note->w_color), &color);
- g_free (color_str);
- }
-
- if (note->font_color)
- color_str = g_strdup (note->font_color);
- else
- {
- color_str = g_settings_get_string (stickynotes->settings, "default-font-color");
- }
-
- if (color_str)
- {
- GdkRGBA font_color;
- gdk_rgba_parse (&font_color, color_str);
- gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (note->w_font_color), &font_color);
- g_free (color_str);
- }
-
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(note->w_def_font),
- note->font == NULL);
- if (note->font)
- gtk_font_button_set_font_name (GTK_FONT_BUTTON (note->w_font),
- note->font);
-
- gtk_widget_show (note->w_properties);
-
- stickynotes_save();
+ char *color_str = NULL;
+
+ gtk_entry_set_text (GTK_ENTRY (note->w_entry),
+ gtk_label_get_text (GTK_LABEL (note->w_title)));
+
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (note->w_def_color),
+ note->color == NULL);
+
+ if (note->color)
+ color_str = g_strdup (note->color);
+ else {
+ color_str = g_settings_get_string (stickynotes->settings,
+ "default-color");
+ }
+
+ if (color_str) {
+ GdkRGBA color;
+ gdk_rgba_parse (&color, color_str);
+ gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (note->w_color),
+ &color);
+ g_free (color_str);
+ }
+
+ if (note->font_color)
+ color_str = g_strdup (note->font_color);
+ else {
+ color_str = g_settings_get_string (stickynotes->settings,
+ "default-font-color");
+ }
+
+ if (color_str) {
+ GdkRGBA font_color;
+ gdk_rgba_parse (&font_color, color_str);
+ gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (note->w_font_color),
+ &font_color);
+ g_free (color_str);
+ }
+
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (note->w_def_font),
+ note->font == NULL);
+ if (note->font)
+ gtk_font_button_set_font_name (GTK_FONT_BUTTON (note->w_font),
+ note->font);
+
+ gtk_widget_show (note->w_properties);
+
+ stickynotes_save ();
}
static void
-response_cb (GtkWidget *dialog, gint id, gpointer data)
+response_cb (GtkWidget *dialog,
+ gint id, gpointer data)
{
- if (id == GTK_RESPONSE_HELP)
- gtk_show_uri_on_window (GTK_WINDOW (dialog),
- "help:mate-stickynotes-applet/stickynotes-settings-individual",
- gtk_get_current_event_time (),
- NULL);
- else if (id == GTK_RESPONSE_CLOSE)
- gtk_widget_hide (dialog);
+ if (id == GTK_RESPONSE_HELP)
+ gtk_show_uri_on_window (GTK_WINDOW (dialog),
+ "help:mate-stickynotes-applet/stickynotes-settings-individual",
+ gtk_get_current_event_time (),
+ NULL);
+ else if (id == GTK_RESPONSE_CLOSE)
+ gtk_widget_hide (dialog);
}
/* Check if a sticky note is empty */
-gboolean stickynote_get_empty(const StickyNote *note)
+gboolean
+stickynote_get_empty (const StickyNote *note)
{
- return gtk_text_buffer_get_char_count(gtk_text_view_get_buffer(GTK_TEXT_VIEW(note->w_body))) == 0;
+ return gtk_text_buffer_get_char_count (gtk_text_view_get_buffer (GTK_TEXT_VIEW (note->w_body))) == 0;
}
/* Set the sticky note title */
-void stickynote_set_title(StickyNote *note, const gchar *title)
+void
+stickynote_set_title (StickyNote *note,
+ const gchar *title)
{
- /* If title is NULL, use the current date as the title. */
- if (!title) {
- GDateTime *now;
- gchar *date_title;
- gchar *date_format;
-
- date_format = g_settings_get_string (stickynotes->settings, "date-format");
- if (!date_format)
- date_format = g_strdup ("%x");
-
- now = g_date_time_new_now_local ();
- date_title = g_date_time_format (now, date_format);
-
- gtk_window_set_title(GTK_WINDOW(note->w_window), date_title);
- gtk_label_set_text(GTK_LABEL (note->w_title), date_title);
-
- g_date_time_unref (now);
- g_free(date_title);
- g_free(date_format);
- }
- else {
- gtk_window_set_title(GTK_WINDOW(note->w_window), title);
- gtk_label_set_text(GTK_LABEL (note->w_title), title);
- }
+ /* If title is NULL, use the current date as the title. */
+ if (!title) {
+ GDateTime *now;
+ gchar *date_title;
+ gchar *date_format;
+
+ date_format = g_settings_get_string (stickynotes->settings, "date-format");
+ if (!date_format)
+ date_format = g_strdup ("%x");
+
+ now = g_date_time_new_now_local ();
+ date_title = g_date_time_format (now, date_format);
+
+ gtk_window_set_title (GTK_WINDOW (note->w_window), date_title);
+ gtk_label_set_text (GTK_LABEL (note->w_title), date_title);
+
+ g_date_time_unref (now);
+ g_free (date_title);
+ g_free (date_format);
+ }
+ else {
+ gtk_window_set_title (GTK_WINDOW (note->w_window), title);
+ gtk_label_set_text (GTK_LABEL (note->w_title), title);
+ }
}
/* Set the sticky note color */
void
stickynote_set_color (StickyNote *note,
- const gchar *color_str,
- const gchar *font_color_str,
- gboolean save)
+ const gchar *color_str,
+ const gchar *font_color_str,
+ gboolean save)
{
- char *color_str_actual, *font_color_str_actual;
- gboolean force_default, use_system_color;
-
- if (save) {
- if (note->color)
- g_free (note->color);
- if (note->font_color)
- g_free (note->font_color);
-
- note->color = color_str ?
- g_strdup (color_str) : NULL;
- note->font_color = font_color_str ?
- g_strdup (font_color_str) : NULL;
-
- gtk_widget_set_sensitive (note->w_color_label,
- note->color != NULL);
- gtk_widget_set_sensitive (note->w_font_color_label,
- note->font_color != NULL);
- gtk_widget_set_sensitive (note->w_color,
- note->color != NULL);
- gtk_widget_set_sensitive (note->w_font_color,
- note->color != NULL);
- }
-
- force_default = g_settings_get_boolean (stickynotes->settings, "force-default");
- use_system_color = g_settings_get_boolean (stickynotes->settings, "use-system-color");
-
- /* If "force_default" is enabled or color_str is NULL,
- * then we use the default color instead of color_str. */
- if (!color_str || force_default)
- {
- if (use_system_color)
- color_str_actual = NULL;
- else
- color_str_actual = g_settings_get_string (stickynotes->settings, "default-color");
- }
- else
- color_str_actual = g_strdup (color_str);
-
- if (!font_color_str || force_default)
- {
- if (use_system_color)
- font_color_str_actual = NULL;
- else
- font_color_str_actual = g_settings_get_string (stickynotes->settings, "default-font-color");
- }
- else
- font_color_str_actual = g_strdup (font_color_str);
-
- /* Do not use custom colors if "use_system_color" is enabled */
- if (color_str_actual) {
- GdkRGBA colors[4];
- gint i;
-
- for (i = 0; i <= 3; i++)
- {
- gdk_rgba_parse (&colors[i], color_str_actual);
- colors[i].red = (colors[i].red * (10 - i)) / 10;
- colors[i].green = (colors[i].green * (10 - i)) / 10;
- colors[i].blue = (colors[i].blue * (10 - i)) / 10;
- }
-
- gtk_widget_override_background_color (note->w_window, GTK_STATE_FLAG_NORMAL, &colors[0]);
- gtk_widget_override_background_color (note->w_body, GTK_STATE_FLAG_NORMAL, &colors[0]);
- gtk_widget_override_background_color (note->w_lock, GTK_STATE_FLAG_NORMAL, &colors[0]);
- gtk_widget_override_background_color (note->w_close, GTK_STATE_FLAG_NORMAL, &colors[0]);
- gtk_widget_override_background_color (note->w_resize_se, GTK_STATE_FLAG_NORMAL, &colors[0]);
- gtk_widget_override_background_color (note->w_resize_sw, GTK_STATE_FLAG_NORMAL, &colors[0]);
- } else {
- gtk_widget_override_background_color (note->w_window, GTK_STATE_FLAG_NORMAL, NULL);
- gtk_widget_override_background_color (note->w_body, GTK_STATE_FLAG_NORMAL, NULL);
- gtk_widget_override_background_color (note->w_lock, GTK_STATE_FLAG_NORMAL, NULL);
- gtk_widget_override_background_color (note->w_close, GTK_STATE_FLAG_NORMAL, NULL);
- gtk_widget_override_background_color (note->w_resize_se, GTK_STATE_FLAG_NORMAL, NULL);
- gtk_widget_override_background_color (note->w_resize_sw, GTK_STATE_FLAG_NORMAL, NULL);
- }
-
- if (font_color_str_actual)
- {
- GdkRGBA color;
-
- gdk_rgba_parse (&color, font_color_str_actual);
-
- gtk_widget_override_color (note->w_window, GTK_STATE_FLAG_NORMAL, &color);
- gtk_widget_override_color (note->w_body, GTK_STATE_FLAG_NORMAL, &color);
- }
- else
- {
- gtk_widget_override_color (note->w_window, GTK_STATE_FLAG_NORMAL, NULL);
- gtk_widget_override_color (note->w_body, GTK_STATE_FLAG_NORMAL, NULL);
- }
-
- if (color_str_actual)
- g_free (color_str_actual);
- if (font_color_str_actual)
- g_free (font_color_str_actual);
+ char *color_str_actual, *font_color_str_actual;
+ gboolean force_default, use_system_color;
+
+ if (save) {
+ if (note->color)
+ g_free (note->color);
+ if (note->font_color)
+ g_free (note->font_color);
+
+ note->color = color_str ? g_strdup (color_str) : NULL;
+ note->font_color = font_color_str ? g_strdup (font_color_str) : NULL;
+
+ gtk_widget_set_sensitive (note->w_color_label,
+ note->color != NULL);
+ gtk_widget_set_sensitive (note->w_font_color_label,
+ note->font_color != NULL);
+ gtk_widget_set_sensitive (note->w_color,
+ note->color != NULL);
+ gtk_widget_set_sensitive (note->w_font_color,
+ note->color != NULL);
+ }
+
+ force_default = g_settings_get_boolean (stickynotes->settings,
+ "force-default");
+ use_system_color = g_settings_get_boolean (stickynotes->settings,
+ "use-system-color");
+
+ /* If "force_default" is enabled or color_str is NULL,
+ * then we use the default color instead of color_str. */
+ if (!color_str || force_default) {
+ if (use_system_color)
+ color_str_actual = NULL;
+ else
+ color_str_actual = g_settings_get_string (stickynotes->settings,
+ "default-color");
+ } else
+ color_str_actual = g_strdup (color_str);
+
+ if (!font_color_str || force_default) {
+ if (use_system_color)
+ font_color_str_actual = NULL;
+ else
+ font_color_str_actual = g_settings_get_string (stickynotes->settings,
+ "default-font-color");
+ } else
+ font_color_str_actual = g_strdup (font_color_str);
+
+ /* Do not use custom colors if "use_system_color" is enabled */
+ if (color_str_actual) {
+ GdkRGBA colors[4];
+ gint i;
+
+ for (i = 0; i <= 3; i++) {
+ gdk_rgba_parse (&colors[i], color_str_actual);
+ colors[i].red = (colors[i].red * (10 - i)) / 10;
+ colors[i].green = (colors[i].green * (10 - i)) / 10;
+ colors[i].blue = (colors[i].blue * (10 - i)) / 10;
+ }
+
+ gtk_widget_override_background_color (note->w_window,
+ GTK_STATE_FLAG_NORMAL,
+ &colors[0]);
+ gtk_widget_override_background_color (note->w_body,
+ GTK_STATE_FLAG_NORMAL,
+ &colors[0]);
+ gtk_widget_override_background_color (note->w_lock,
+ GTK_STATE_FLAG_NORMAL,
+ &colors[0]);
+ gtk_widget_override_background_color (note->w_close,
+ GTK_STATE_FLAG_NORMAL,
+ &colors[0]);
+ gtk_widget_override_background_color (note->w_resize_se,
+ GTK_STATE_FLAG_NORMAL,
+ &colors[0]);
+ gtk_widget_override_background_color (note->w_resize_sw,
+ GTK_STATE_FLAG_NORMAL,
+ &colors[0]);
+ } else {
+ gtk_widget_override_background_color (note->w_window,
+ GTK_STATE_FLAG_NORMAL,
+ NULL);
+ gtk_widget_override_background_color (note->w_body,
+ GTK_STATE_FLAG_NORMAL,
+ NULL);
+ gtk_widget_override_background_color (note->w_lock,
+ GTK_STATE_FLAG_NORMAL,
+ NULL);
+ gtk_widget_override_background_color (note->w_close,
+ GTK_STATE_FLAG_NORMAL,
+ NULL);
+ gtk_widget_override_background_color (note->w_resize_se,
+ GTK_STATE_FLAG_NORMAL,
+ NULL);
+ gtk_widget_override_background_color (note->w_resize_sw,
+ GTK_STATE_FLAG_NORMAL,
+ NULL);
+ }
+
+ if (font_color_str_actual) {
+ GdkRGBA color;
+
+ gdk_rgba_parse (&color, font_color_str_actual);
+
+ gtk_widget_override_color (note->w_window,
+ GTK_STATE_FLAG_NORMAL,
+ &color);
+ gtk_widget_override_color (note->w_body,
+ GTK_STATE_FLAG_NORMAL,
+ &color);
+ } else {
+ gtk_widget_override_color (note->w_window,
+ GTK_STATE_FLAG_NORMAL,
+ NULL);
+ gtk_widget_override_color (note->w_body,
+ GTK_STATE_FLAG_NORMAL,
+ NULL);
+ }
+
+ if (color_str_actual)
+ g_free (color_str_actual);
+ if (font_color_str_actual)
+ g_free (font_color_str_actual);
}
/* Set the sticky note font */
void
-stickynote_set_font (StickyNote *note, const gchar *font_str, gboolean save)
+stickynote_set_font (StickyNote *note,
+ const gchar *font_str,
+ gboolean save)
{
- PangoFontDescription *font_desc;
- gchar *font_str_actual;
-
- if (save) {
- g_free (note->font);
- note->font = font_str ? g_strdup (font_str) : NULL;
-
- gtk_widget_set_sensitive (note->w_font_label, note->font != NULL);
- gtk_widget_set_sensitive(note->w_font, note->font != NULL);
- }
-
- /* If "force_default" is enabled or font_str is NULL,
- * then we use the default font instead of font_str. */
- if (!font_str || g_settings_get_boolean (stickynotes->settings, "force-default"))
- {
- if (g_settings_get_boolean (stickynotes->settings, "use-system-font"))
- font_str_actual = NULL;
- else
- font_str_actual = g_settings_get_string (stickynotes->settings, "default-font");
- }
- else
- font_str_actual = g_strdup (font_str);
-
- /* Do not use custom fonts if "use_system_font" is enabled */
- font_desc = font_str_actual ?
- pango_font_description_from_string (font_str_actual): NULL;
-
- /* Apply the style to the widgets */
- gtk_widget_override_font (note->w_window, font_desc);
- gtk_widget_override_font (note->w_body, font_desc);
-
- g_free (font_str_actual);
- pango_font_description_free (font_desc);
+ PangoFontDescription *font_desc;
+ gchar *font_str_actual;
+
+ if (save) {
+ g_free (note->font);
+ note->font = font_str ? g_strdup (font_str) : NULL;
+
+ gtk_widget_set_sensitive (note->w_font_label,
+ note->font != NULL);
+ gtk_widget_set_sensitive (note->w_font,
+ note->font != NULL);
+ }
+
+ /* If "force_default" is enabled or font_str is NULL,
+ * then we use the default font instead of font_str. */
+ if (!font_str || g_settings_get_boolean (stickynotes->settings,
+ "force-default")) {
+ if (g_settings_get_boolean (stickynotes->settings,
+ "use-system-font"))
+ font_str_actual = NULL;
+ else
+ font_str_actual = g_settings_get_string (stickynotes->settings,
+ "default-font");
+ } else
+ font_str_actual = g_strdup (font_str);
+
+ /* Do not use custom fonts if "use_system_font" is enabled */
+ font_desc = font_str_actual ?
+ pango_font_description_from_string (font_str_actual): NULL;
+
+ /* Apply the style to the widgets */
+ gtk_widget_override_font (note->w_window, font_desc);
+ gtk_widget_override_font (note->w_body, font_desc);
+
+ g_free (font_str_actual);
+ pango_font_description_free (font_desc);
}
/* Lock/Unlock a sticky note from editing */
-void stickynote_set_locked(StickyNote *note, gboolean locked)
+void
+stickynote_set_locked (StickyNote *note,
+ gboolean locked)
{
- note->locked = locked;
-
- /* Set cursor visibility and editability */
- gtk_text_view_set_editable(GTK_TEXT_VIEW(note->w_body), !locked);
- gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(note->w_body), !locked);
-
- /* Show appropriate icon and tooltip */
- if (locked) {
- gtk_image_set_from_icon_name (note->img_lock, STICKYNOTES_STOCK_LOCKED, GTK_ICON_SIZE_MENU);
- gtk_widget_set_tooltip_text(note->w_lock, _("This note is locked."));
- }
- else {
- gtk_image_set_from_icon_name (note->img_lock, STICKYNOTES_STOCK_UNLOCKED, GTK_ICON_SIZE_MENU);
- gtk_widget_set_tooltip_text(note->w_lock, _("This note is unlocked."));
- }
-
- gtk_image_set_pixel_size (note->img_lock, STICKYNOTES_ICON_SIZE);
-
- gtk_toggle_action_set_active(note->ta_lock_toggle_item, locked);
-
- stickynotes_applet_update_menus();
+ note->locked = locked;
+
+ /* Set cursor visibility and editability */
+ gtk_text_view_set_editable (GTK_TEXT_VIEW (note->w_body),
+ !locked);
+ gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (note->w_body),
+ !locked);
+
+ /* Show appropriate icon and tooltip */
+ if (locked) {
+ gtk_image_set_from_icon_name (note->img_lock,
+ STICKYNOTES_STOCK_LOCKED,
+ GTK_ICON_SIZE_MENU);
+ gtk_widget_set_tooltip_text (note->w_lock,
+ _("This note is locked."));
+ } else {
+ gtk_image_set_from_icon_name (note->img_lock,
+ STICKYNOTES_STOCK_UNLOCKED,
+ GTK_ICON_SIZE_MENU);
+ gtk_widget_set_tooltip_text (note->w_lock,
+ _("This note is unlocked."));
+ }
+
+ gtk_image_set_pixel_size (note->img_lock,
+ STICKYNOTES_ICON_SIZE);
+
+ gtk_toggle_action_set_active (note->ta_lock_toggle_item,
+ locked);
+
+ stickynotes_applet_update_menus ();
}
/* Show/Hide a sticky note */
void
-stickynote_set_visible (StickyNote *note, gboolean visible)
+stickynote_set_visible (StickyNote *note,
+ gboolean visible)
{
- if (visible)
- {
- gtk_window_present (GTK_WINDOW (note->w_window));
-
- if (note->x != -1 || note->y != -1)
- gtk_window_move (GTK_WINDOW (note->w_window),
- note->x, note->y);
- /* Put the note on all workspaces if necessary. */
- if (g_settings_get_boolean (stickynotes->settings, "sticky"))
- gtk_window_stick(GTK_WINDOW(note->w_window));
- else if (note->workspace > 0)
- {
-#if 0
- WnckWorkspace *wnck_ws;
- gulong xid;
- WnckWindow *wnck_win;
- WnckScreen *wnck_screen;
-
- g_print ("set_visible(): workspace = %i\n",
- note->workspace);
-
- xid = GDK_WINDOW_XID (note->w_window->window);
- wnck_screen = wnck_screen_get_default ();
- wnck_win = wnck_window_get (xid);
- wnck_ws = wnck_screen_get_workspace (
- wnck_screen,
- note->workspace - 1);
- if (wnck_win && wnck_ws)
- wnck_window_move_to_workspace (
- wnck_win, wnck_ws);
- else
- g_print ("set_visible(): errr\n");
-#endif
- xstuff_change_workspace (GTK_WINDOW (note->w_window),
- note->workspace - 1);
- }
- }
- else {
- /* Hide sticky note */
- int x, y, width, height;
- stickynotes_applet_panel_icon_get_geometry (&x, &y, &width, &height);
- set_icon_geometry (gtk_widget_get_window (GTK_WIDGET (note->w_window)),
- x, y, width, height);
- gtk_window_iconify(GTK_WINDOW (note->w_window));
- }
+ if (visible) {
+ gtk_window_present (GTK_WINDOW (note->w_window));
+
+ if (note->x != -1 || note->y != -1)
+ gtk_window_move (GTK_WINDOW (note->w_window),
+ note->x, note->y);
+
+ /* Put the note on all workspaces if necessary. */
+ if (g_settings_get_boolean (stickynotes->settings, "sticky"))
+ gtk_window_stick (GTK_WINDOW (note->w_window));
+
+ else if (note->workspace > 0)
+ xstuff_change_workspace (GTK_WINDOW (note->w_window),
+ note->workspace - 1);
+ } else {
+ /* Hide sticky note */
+ int x, y, width, height;
+
+ stickynotes_applet_panel_icon_get_geometry (&x, &y,
+ &width, &height);
+ set_icon_geometry (gtk_widget_get_window (GTK_WIDGET (note->w_window)),
+ x, y, width, height);
+ gtk_window_iconify (GTK_WINDOW (note->w_window));
+ }
}
/* Add a sticky note */
-void stickynotes_add (GdkScreen *screen)
+void
+stickynotes_add (GdkScreen *screen)
{
- StickyNote *note;
+ StickyNote *note;
- note = stickynote_new (screen);
+ note = stickynote_new (screen);
- stickynotes->notes = g_list_append(stickynotes->notes, note);
- stickynotes_applet_update_tooltips();
- stickynotes_save();
- stickynote_set_visible (note, TRUE);
+ stickynotes->notes = g_list_append (stickynotes->notes, note);
+ stickynotes_applet_update_tooltips ();
+ stickynotes_save ();
+ stickynote_set_visible (note, TRUE);
}
/* Remove a sticky note with confirmation, if needed */
-void stickynotes_remove(StickyNote *note)
+void
+stickynotes_remove (StickyNote *note)
{
- GtkBuilder *builder;
- GtkWidget *dialog;
+ GtkBuilder *builder;
+ GtkWidget *dialog;
- builder = gtk_builder_new ();
- gtk_builder_add_from_resource (builder, GRESOURCE "sticky-notes-delete.ui", NULL);
+ builder = gtk_builder_new ();
+ gtk_builder_add_from_resource (builder,
+ GRESOURCE "sticky-notes-delete.ui",
+ NULL);
- dialog = GTK_WIDGET (gtk_builder_get_object (builder, "delete_dialog"));
+ dialog = GTK_WIDGET (gtk_builder_get_object (builder,
+ "delete_dialog"));
- gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(note->w_window));
+ gtk_window_set_transient_for (GTK_WINDOW (dialog),
+ GTK_WINDOW (note->w_window));
- if (stickynote_get_empty(note)
- || !g_settings_get_boolean (stickynotes->settings, "confirm-deletion")
- || gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK) {
+ if (stickynote_get_empty (note)
+ || !g_settings_get_boolean (stickynotes->settings,
+ "confirm-deletion")
+ || gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK) {
- /* Remove the note from the linked-list of all notes */
- stickynotes->notes = g_list_remove_all (stickynotes->notes, note);
+ /* Remove the note from the linked-list of all notes */
+ stickynotes->notes = g_list_remove_all (stickynotes->notes,
+ note);
- /* Destroy the note */
- stickynote_free (note);
+ /* Destroy the note */
+ stickynote_free (note);
- /* Update tooltips */
- stickynotes_applet_update_tooltips();
+ /* Update tooltips */
+ stickynotes_applet_update_tooltips ();
- /* Save notes */
- stickynotes_save();
- }
+ /* Save notes */
+ stickynotes_save ();
+ }
- gtk_widget_destroy(dialog);
- g_object_unref(builder);
+ gtk_widget_destroy (dialog);
+ g_object_unref (builder);
}
/* Save all sticky notes in an XML configuration file */
gboolean
stickynotes_save_now (void)
{
- WnckScreen *wnck_screen;
- const gchar *title;
- GtkTextBuffer *buffer;
- GtkTextIter start, end;
- gchar *body;
-
- gint i;
-
- /* Create a new XML document */
- xmlDocPtr doc = xmlNewDoc(XML_CHAR ("1.0"));
- xmlNodePtr root = xmlNewDocNode(doc, NULL, XML_CHAR ("stickynotes"), NULL);
-
- xmlDocSetRootElement(doc, root);
- xmlNewProp(root, XML_CHAR("version"), XML_CHAR (VERSION));
-
- wnck_screen = wnck_screen_get_default ();
- wnck_screen_force_update (wnck_screen);
-
- /* For all sticky notes */
- for (i = 0; i < g_list_length(stickynotes->notes); i++) {
- WnckWindow *wnck_win;
- gulong xid = 0;
-
- /* Access the current note in the list */
- StickyNote *note = g_list_nth_data(stickynotes->notes, i);
-
- /* Retrieve the window size of the note */
- gchar *w_str = g_strdup_printf("%d", note->w);
- gchar *h_str = g_strdup_printf("%d", note->h);
-
- /* Retrieve the window position of the note */
- gchar *x_str = g_strdup_printf("%d", note->x);
- gchar *y_str = g_strdup_printf("%d", note->y);
-
- xid = GDK_WINDOW_XID (gtk_widget_get_window (note->w_window));
- wnck_win = wnck_window_get (xid);
-
- if (!g_settings_get_boolean (stickynotes->settings, "sticky") &&
- wnck_win)
- note->workspace = 1 +
- wnck_workspace_get_number (
- wnck_window_get_workspace (wnck_win));
- else
- note->workspace = 0;
-
- /* Retrieve the title of the note */
- title = gtk_label_get_text(GTK_LABEL(note->w_title));
-
- /* Retrieve body contents of the note */
- buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(note->w_body));
-
- gtk_text_buffer_get_bounds(buffer, &start, &end);
- body = gtk_text_iter_get_text(&start, &end);
-
- /* Save the note as a node in the XML document */
- {
- xmlNodePtr node = xmlNewTextChild(root, NULL, XML_CHAR ("note"),
- XML_CHAR (body));
- xmlNewProp(node, XML_CHAR ("title"), XML_CHAR (title));
- if (note->color)
- xmlNewProp (node, XML_CHAR ("color"), XML_CHAR (note->color));
- if (note->font_color)
- xmlNewProp (node, XML_CHAR ("font_color"),
- XML_CHAR (note->font_color));
- if (note->font)
- xmlNewProp (node, XML_CHAR ("font"), XML_CHAR (note->font));
- if (note->locked)
- xmlNewProp (node, XML_CHAR ("locked"), XML_CHAR ("true"));
- xmlNewProp (node, XML_CHAR ("x"), XML_CHAR (x_str));
- xmlNewProp (node, XML_CHAR ("y"), XML_CHAR (y_str));
- xmlNewProp (node, XML_CHAR ("w"), XML_CHAR (w_str));
- xmlNewProp (node, XML_CHAR ("h"), XML_CHAR (h_str));
- if (note->workspace > 0)
- {
- char *workspace_str;
-
- workspace_str = g_strdup_printf ("%i",
- note->workspace);
- xmlNewProp (node, XML_CHAR ("workspace"), XML_CHAR (workspace_str));
- g_free (workspace_str);
- }
- }
-
- /* Now that it has been saved, reset the modified flag */
- gtk_text_buffer_set_modified(buffer, FALSE);
-
- g_free(x_str);
- g_free(y_str);
- g_free(w_str);
- g_free(h_str);
- g_free(body);
- }
-
- /* The XML file is $HOME/.config/mate/stickynotes-applet, most probably */
- {
- gchar* path = g_build_filename(g_get_user_config_dir(), "mate", NULL);
- gchar* file = g_build_filename(path, "stickynotes-applet.xml", NULL);
- g_mkdir_with_parents(path, S_IRWXU);
- g_free(path);
-
- xmlSaveFormatFile(file, doc, 1);
-
- g_free(file);
- }
-
- xmlFreeDoc(doc);
-
- save_scheduled = FALSE;
-
- return FALSE;
+ WnckScreen *wnck_screen;
+ const gchar *title;
+ GtkTextBuffer *buffer;
+ GtkTextIter start, end;
+ gchar *body;
+
+ gint i;
+
+ /* Create a new XML document */
+ xmlDocPtr doc = xmlNewDoc (XML_CHAR ("1.0"));
+ xmlNodePtr root = xmlNewDocNode (doc, NULL, XML_CHAR ("stickynotes"), NULL);
+
+ xmlDocSetRootElement (doc, root);
+ xmlNewProp (root, XML_CHAR ("version"), XML_CHAR (VERSION));
+
+ wnck_screen = wnck_screen_get_default ();
+ wnck_screen_force_update (wnck_screen);
+
+ /* For all sticky notes */
+ for (i = 0; i < g_list_length (stickynotes->notes); i++) {
+ WnckWindow *wnck_win;
+ gulong xid = 0;
+
+ /* Access the current note in the list */
+ StickyNote *note = g_list_nth_data (stickynotes->notes, i);
+
+ /* Retrieve the window size of the note */
+ gchar *w_str = g_strdup_printf ("%d", note->w);
+ gchar *h_str = g_strdup_printf ("%d", note->h);
+
+ /* Retrieve the window position of the note */
+ gchar *x_str = g_strdup_printf ("%d", note->x);
+ gchar *y_str = g_strdup_printf ("%d", note->y);
+
+ xid = GDK_WINDOW_XID (gtk_widget_get_window (note->w_window));
+ wnck_win = wnck_window_get (xid);
+
+ if (!g_settings_get_boolean (stickynotes->settings, "sticky") && wnck_win)
+ note->workspace = 1 +
+ wnck_workspace_get_number (wnck_window_get_workspace (wnck_win));
+ else
+ note->workspace = 0;
+
+ /* Retrieve the title of the note */
+ title = gtk_label_get_text (GTK_LABEL (note->w_title));
+
+ /* Retrieve body contents of the note */
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (note->w_body));
+
+ gtk_text_buffer_get_bounds (buffer, &start, &end);
+ body = gtk_text_iter_get_text (&start, &end);
+
+ /* Save the note as a node in the XML document */
+ {
+ xmlNodePtr node = xmlNewTextChild (root, NULL,
+ XML_CHAR ("note"),
+ XML_CHAR (body));
+
+ xmlNewProp (node, XML_CHAR ("title"),
+ XML_CHAR (title));
+
+ if (note->color)
+ xmlNewProp (node, XML_CHAR ("color"),
+ XML_CHAR (note->color));
+
+ if (note->font_color)
+ xmlNewProp (node, XML_CHAR ("font_color"),
+ XML_CHAR (note->font_color));
+
+ if (note->font)
+ xmlNewProp (node, XML_CHAR ("font"),
+ XML_CHAR (note->font));
+
+ if (note->locked)
+ xmlNewProp (node, XML_CHAR ("locked"),
+ XML_CHAR ("true"));
+
+ xmlNewProp (node, XML_CHAR ("x"), XML_CHAR (x_str));
+ xmlNewProp (node, XML_CHAR ("y"), XML_CHAR (y_str));
+ xmlNewProp (node, XML_CHAR ("w"), XML_CHAR (w_str));
+ xmlNewProp (node, XML_CHAR ("h"), XML_CHAR (h_str));
+ if (note->workspace > 0) {
+ char *workspace_str;
+
+ workspace_str = g_strdup_printf ("%i", note->workspace);
+ xmlNewProp (node, XML_CHAR ("workspace"), XML_CHAR (workspace_str));
+ g_free (workspace_str);
+ }
+ }
+
+ /* Now that it has been saved, reset the modified flag */
+ gtk_text_buffer_set_modified (buffer, FALSE);
+
+ g_free (x_str);
+ g_free (y_str);
+ g_free (w_str);
+ g_free (h_str);
+ g_free (body);
+ }
+
+ /* The XML file is $HOME/.config/mate/stickynotes-applet,
+ most probably */
+ {
+ gchar* path = g_build_filename (g_get_user_config_dir (),
+ "mate", NULL);
+ gchar* file = g_build_filename (path, "stickynotes-applet.xml",
+ NULL);
+ g_mkdir_with_parents (path, S_IRWXU);
+ g_free (path);
+
+ xmlSaveFormatFile (file, doc, 1);
+
+ g_free (file);
+ }
+
+ xmlFreeDoc (doc);
+
+ save_scheduled = FALSE;
+
+ return FALSE;
}
void
stickynotes_save (void)
{
- /* If a save isn't already scheduled, save everything a minute from now. */
- if (!save_scheduled) {
- g_timeout_add_seconds (60, (GSourceFunc) stickynotes_save_now, NULL);
- save_scheduled = TRUE;
- }
+ /* If a save isn't already scheduled, save everything a minute from now. */
+ if (!save_scheduled) {
+ g_timeout_add_seconds (60, (GSourceFunc) stickynotes_save_now, NULL);
+ save_scheduled = TRUE;
+ }
}
/* Load all sticky notes from an XML configuration file */
void
stickynotes_load (GdkScreen *screen)
{
- xmlDocPtr doc = NULL;
- xmlNodePtr root;
- xmlNodePtr node;
- /* WnckScreen *wnck_screen; */
- GList *new_notes, *tmp1; /* Lists of StickyNote*'s */
- GList *new_nodes; /* Lists of xmlNodePtr's */
- int x, y, w, h;
-
- /* The XML file is $HOME/.config/mate/stickynotes-applet, most probably */
- {
- gchar* file = g_build_filename(g_get_user_config_dir(), "mate", "stickynotes-applet.xml", NULL);
-
- if (g_file_test(file, G_FILE_TEST_EXISTS))
- {
- /* load file */
- doc = xmlParseFile(file);
- }
- else
- {
- /* old one */
- g_free(file);
-
- file = g_build_filename(g_get_home_dir(), ".mate2", "stickynotes_applet", NULL);
-
- if (g_file_test(file, G_FILE_TEST_EXISTS))
- {
- /* load file */
- doc = xmlParseFile(file);
- }
- }
-
- g_free(file);
- }
-
- /* If the XML file does not exist, create a blank one */
- if (!doc)
- {
- stickynotes_save();
- return;
- }
-
- /* If the XML file is corrupted/incorrect, create a blank one */
- root = xmlDocGetRootElement(doc);
- if (!root || xmlStrcmp(root->name, XML_CHAR ("stickynotes")))
- {
- xmlFreeDoc(doc);
- stickynotes_save();
- return;
- }
-
- node = root->xmlChildrenNode;
-
- /* For all children of the root node (ie all sticky notes) */
- new_notes = NULL;
- new_nodes = NULL;
- while (node) {
- if (!xmlStrcmp(node->name, (const xmlChar *) "note"))
- {
- StickyNote *note;
-
- /* Retrieve and set the window size of the note */
- {
- gchar *w_str = (gchar *)xmlGetProp (node, XML_CHAR ("w"));
- gchar *h_str = (gchar *)xmlGetProp (node, XML_CHAR ("h"));
- if (w_str && h_str)
- {
- w = atoi (w_str);
- h = atoi (h_str);
- }
- else
- {
- w = 0;
- h = 0;
- }
-
- g_free (w_str);
- g_free (h_str);
- }
-
- /* Retrieve and set the window position of the note */
- {
- gchar *x_str = (gchar *)xmlGetProp (node, XML_CHAR ("x"));
- gchar *y_str = (gchar *)xmlGetProp (node, XML_CHAR ("y"));
-
- if (x_str && y_str)
- {
- x = atoi (x_str);
- y = atoi (y_str);
- }
- else
- {
- x = -1;
- y = -1;
- }
-
- g_free (x_str);
- g_free (y_str);
- }
-
- /* Create a new note */
- note = stickynote_new_aux (screen, x, y, w, h);
- stickynotes->notes = g_list_append (stickynotes->notes,
- note);
- new_notes = g_list_append (new_notes, note);
- new_nodes = g_list_append (new_nodes, node);
-
- /* Retrieve and set title of the note */
- {
- gchar *title = (gchar *)xmlGetProp(node, XML_CHAR ("title"));
- if (title)
- stickynote_set_title (note, title);
- g_free (title);
- }
-
- /* Retrieve and set the color of the note */
- {
- gchar *color_str;
- gchar *font_color_str;
-
- color_str = (gchar *)xmlGetProp (node, XML_CHAR ("color"));
- font_color_str = (gchar *)xmlGetProp (node, XML_CHAR ("font_color"));
-
- if (color_str || font_color_str)
- stickynote_set_color (note,
- color_str,
- font_color_str,
- TRUE);
- g_free (color_str);
- g_free (font_color_str);
- }
-
- /* Retrieve and set the font of the note */
- {
- gchar *font_str = (gchar *)xmlGetProp (node, XML_CHAR ("font"));
- if (font_str)
- stickynote_set_font (note, font_str,
- TRUE);
- g_free (font_str);
- }
-
- /* Retrieve the workspace */
- {
- char *workspace_str;
-
- workspace_str = (gchar *)xmlGetProp (node, XML_CHAR ("workspace"));
- if (workspace_str)
- {
- note->workspace = atoi (workspace_str);
- g_free (workspace_str);
- }
- }
-
- /* Retrieve and set (if any) the body contents of the
- * note */
- {
- gchar *body = (gchar *)xmlNodeListGetString(doc,
- node->xmlChildrenNode, 1);
- if (body) {
- GtkTextBuffer *buffer;
- GtkTextIter start, end;
-
- buffer = gtk_text_view_get_buffer(
- GTK_TEXT_VIEW(note->w_body));
- gtk_text_buffer_get_bounds(
- buffer, &start, &end);
- gtk_text_buffer_insert(buffer,
- &start, body, -1);
- }
- g_free(body);
- }
-
- /* Retrieve and set the locked state of the note,
- * by default unlocked */
- {
- gchar *locked = (gchar *)xmlGetProp(node, XML_CHAR ("locked"));
- if (locked)
- stickynote_set_locked(note,
- !strcmp(locked, "true"));
- g_free(locked);
- }
- }
-
- node = node->next;
- }
-
- tmp1 = new_notes;
- /*
- wnck_screen = wnck_screen_get_default ();
- wnck_screen_force_update (wnck_screen);
- */
-
- while (tmp1)
- {
- StickyNote *note = tmp1->data;
-
- stickynote_set_visible (note, stickynotes->visible);
- tmp1 = tmp1->next;
- }
-
- g_list_free (new_notes);
- g_list_free (new_nodes);
-
- xmlFreeDoc(doc);
+ xmlDocPtr doc = NULL;
+ xmlNodePtr root;
+ xmlNodePtr node;
+ /* WnckScreen *wnck_screen; */
+ GList *new_notes, *tmp1; /* Lists of StickyNote*'s */
+ GList *new_nodes; /* Lists of xmlNodePtr's */
+ int x, y, w, h;
+
+ /* The XML file is $HOME/.config/mate/stickynotes-applet, most probably */
+ gchar* file = g_build_filename (g_get_user_config_dir (),
+ "mate", "stickynotes-applet.xml", NULL);
+
+ if (g_file_test (file, G_FILE_TEST_EXISTS)) {
+ /* load file */
+ doc = xmlParseFile (file);
+ } else {
+ /* old one */
+ g_free (file);
+
+ file = g_build_filename (g_get_home_dir (),
+ ".mate2", "stickynotes_applet", NULL);
+
+ if (g_file_test (file, G_FILE_TEST_EXISTS)) {
+ /* load file */
+ doc = xmlParseFile (file);
+ }
+ }
+ g_free (file);
+
+ /* If the XML file does not exist, create a blank one */
+ if (!doc) {
+ stickynotes_save ();
+ return;
+ }
+
+ /* If the XML file is corrupted/incorrect, create a blank one */
+ root = xmlDocGetRootElement (doc);
+ if (!root || xmlStrcmp (root->name, XML_CHAR ("stickynotes"))) {
+ xmlFreeDoc (doc);
+ stickynotes_save ();
+ return;
+ }
+
+ node = root->xmlChildrenNode;
+
+ /* For all children of the root node (ie all sticky notes) */
+ new_notes = NULL;
+ new_nodes = NULL;
+ while (node) {
+ if (!xmlStrcmp (node->name, (const xmlChar *) "note")) {
+ StickyNote *note;
+
+ /* Retrieve and set the window size of the note */
+ {
+ gchar *w_str = (gchar *)xmlGetProp (node, XML_CHAR ("w"));
+ gchar *h_str = (gchar *)xmlGetProp (node, XML_CHAR ("h"));
+ if (w_str && h_str) {
+ w = atoi (w_str);
+ h = atoi (h_str);
+ } else {
+ w = 0;
+ h = 0;
+ }
+
+ g_free (w_str);
+ g_free (h_str);
+ }
+
+ /* Retrieve and set the window position of the note */
+ {
+ gchar *x_str = (gchar *)xmlGetProp (node, XML_CHAR ("x"));
+ gchar *y_str = (gchar *)xmlGetProp (node, XML_CHAR ("y"));
+
+ if (x_str && y_str) {
+ x = atoi (x_str);
+ y = atoi (y_str);
+ } else {
+ x = -1;
+ y = -1;
+ }
+
+ g_free (x_str);
+ g_free (y_str);
+ }
+
+ /* Create a new note */
+ note = stickynote_new_aux (screen, x, y, w, h);
+ stickynotes->notes = g_list_append (stickynotes->notes,
+ note);
+ new_notes = g_list_append (new_notes, note);
+ new_nodes = g_list_append (new_nodes, node);
+
+ /* Retrieve and set title of the note */
+ {
+ gchar *title = (gchar *)xmlGetProp (node,
+ XML_CHAR ("title"));
+ if (title)
+ stickynote_set_title (note, title);
+
+ g_free (title);
+ }
+
+ /* Retrieve and set the color of the note */
+ {
+ gchar *color_str;
+ gchar *font_color_str;
+
+ color_str = (gchar *)xmlGetProp (node, XML_CHAR ("color"));
+ font_color_str = (gchar *)xmlGetProp (node, XML_CHAR ("font_color"));
+
+ if (color_str || font_color_str)
+ stickynote_set_color (note,
+ color_str,
+ font_color_str,
+ TRUE);
+
+ g_free (color_str);
+ g_free (font_color_str);
+ }
+
+ /* Retrieve and set the font of the note */
+ {
+ gchar *font_str = (gchar *)xmlGetProp (node,
+ XML_CHAR ("font"));
+ if (font_str)
+ stickynote_set_font (note, font_str, TRUE);
+
+ g_free (font_str);
+ }
+
+ /* Retrieve the workspace */
+ {
+ char *workspace_str;
+
+ workspace_str = (gchar *)xmlGetProp (node,
+ XML_CHAR ("workspace"));
+ if (workspace_str) {
+ note->workspace = atoi (workspace_str);
+ g_free (workspace_str);
+ }
+ }
+
+ /* Retrieve and set (if any) the body contents of the
+ * note */
+ {
+ gchar *body = (gchar *)xmlNodeListGetString (doc,
+ node->xmlChildrenNode,
+ 1);
+ if (body) {
+ GtkTextBuffer *buffer;
+ GtkTextIter start, end;
+
+ buffer = gtk_text_view_get_buffer (
+ GTK_TEXT_VIEW (note->w_body));
+ gtk_text_buffer_get_bounds (buffer,
+ &start, &end);
+ gtk_text_buffer_insert (buffer,
+ &start, body, -1);
+ }
+ g_free (body);
+ }
+
+ /* Retrieve and set the locked state of the note,
+ * by default unlocked */
+ {
+ gchar *locked = (gchar *)xmlGetProp (node,
+ XML_CHAR ("locked"));
+ if (locked)
+ stickynote_set_locked (note,
+ !strcmp (locked,
+ "true"));
+ g_free (locked);
+ }
+ }
+
+ node = node->next;
+ }
+
+ tmp1 = new_notes;
+ /*
+ wnck_screen = wnck_screen_get_default ();
+ wnck_screen_force_update (wnck_screen);
+ */
+
+ while (tmp1) {
+ StickyNote *note = tmp1->data;
+
+ stickynote_set_visible (note, stickynotes->visible);
+ tmp1 = tmp1->next;
+ }
+
+ g_list_free (new_notes);
+ g_list_free (new_nodes);
+
+ xmlFreeDoc (doc);
}
diff --git a/stickynotes/stickynotes.h b/stickynotes/stickynotes.h
index e5a969b4..bee35bad 100644
--- a/stickynotes/stickynotes.h
+++ b/stickynotes/stickynotes.h
@@ -28,71 +28,76 @@
typedef struct
{
- GtkWidget *w_window; /* Sticky Note window */
- GtkWidget *w_menu; /* Sticky Note menu */
- GtkWidget *w_properties; /* Sticky Note properties dialog */
-
- GtkWidget *w_entry; /* Sticky Note title entry */
- GtkWidget *w_color; /* Sticky Note color picker */
- GtkWidget *w_color_label; /* Sticky Note color label */
- GtkWidget *w_font_color; /* Sticky Note font color picker */
- GtkWidget *w_font_color_label; /* Sticky Note font color label */
- GtkWidget *w_font; /* Sticky Note font picker */
- GtkWidget *w_font_label; /* Sticky Note font label */
- GtkWidget *w_def_color; /* Sticky Note default color setting */
- GtkWidget *w_def_font; /* Sticky Note default font setting */
-
- GtkWidget *w_title; /* Sticky Note title */
- GtkWidget *w_body; /* Sticky Note text body */
- GtkWidget *w_scroller; /* Sticky Note scroller */
- GtkWidget *w_lock; /* Sticky Note lock button */
- GtkWidget *w_close; /* Sticky Note close button */
- GtkWidget *w_resize_se; /* Sticky Note resize button (south east) */
- GtkWidget *w_resize_sw; /* Sticky Note resize button (south west) */
-
- GtkSourceBuffer *buffer; /* Sticky Note text buffer for undo/redo */
-
- GtkToggleAction *ta_lock_toggle_item; /* Lock item in the popup menu */
-
- GtkImage *img_lock; /* Lock image */
- GtkImage *img_close; /* Close image */
- GtkImage *img_resize_se; /* SE resize image */
- GtkImage *img_resize_sw; /* SW resize image */
-
- gchar *color; /* Note color */
- gchar *font_color; /* Font color */
- gchar *font; /* Note font */
- gboolean locked; /* Note locked state */
-
- gint x; /* Note x-coordinate */
- gint y; /* Note y-coordinate */
- gint w; /* Note width */
- gint h; /* Note height */
-
- int workspace; /* Workspace the note is on */
+ GtkWidget *w_window; /* Sticky Note window */
+ GtkWidget *w_menu; /* Sticky Note menu */
+ GtkWidget *w_properties; /* Sticky Note properties dialog */
+
+ GtkWidget *w_entry; /* Sticky Note title entry */
+ GtkWidget *w_color; /* Sticky Note color picker */
+ GtkWidget *w_color_label; /* Sticky Note color label */
+ GtkWidget *w_font_color; /* Sticky Note font color picker */
+ GtkWidget *w_font_color_label; /* Sticky Note font color label */
+ GtkWidget *w_font; /* Sticky Note font picker */
+ GtkWidget *w_font_label; /* Sticky Note font label */
+ GtkWidget *w_def_color; /* Sticky Note default color setting */
+ GtkWidget *w_def_font; /* Sticky Note default font setting */
+
+ GtkWidget *w_title; /* Sticky Note title */
+ GtkWidget *w_body; /* Sticky Note text body */
+ GtkWidget *w_scroller; /* Sticky Note scroller */
+ GtkWidget *w_lock; /* Sticky Note lock button */
+ GtkWidget *w_close; /* Sticky Note close button */
+ GtkWidget *w_resize_se; /* Sticky Note resize button (south east) */
+ GtkWidget *w_resize_sw; /* Sticky Note resize button (south west) */
+
+ GtkSourceBuffer *buffer; /* Sticky Note text buffer for undo/redo */
+
+ GtkToggleAction *ta_lock_toggle_item; /* Lock item in the popup menu */
+
+ GtkImage *img_lock; /* Lock image */
+ GtkImage *img_close; /* Close image */
+ GtkImage *img_resize_se; /* SE resize image */
+ GtkImage *img_resize_sw; /* SW resize image */
+
+ gchar *color; /* Note color */
+ gchar *font_color; /* Font color */
+ gchar *font; /* Note font */
+ gboolean locked; /* Note locked state */
+
+ gint x; /* Note x-coordinate */
+ gint y; /* Note y-coordinate */
+ gint w; /* Note width */
+ gint h; /* Note height */
+
+ int workspace; /* Workspace the note is on */
} StickyNote;
-StickyNote * stickynote_new(GdkScreen *screen);
-void stickynote_free(StickyNote *note);
+StickyNote * stickynote_new (GdkScreen *screen);
+void stickynote_free (StickyNote *note);
-gboolean stickynote_get_empty(const StickyNote *note);
+gboolean stickynote_get_empty (const StickyNote *note);
-void stickynote_set_title(StickyNote *note, const gchar* title);
+void stickynote_set_title (StickyNote *note,
+ const gchar *title);
void stickynote_set_color (StickyNote *note,
- const gchar *color_str,
- const gchar *font_color_str,
- gboolean save);
-void stickynote_set_font(StickyNote *note, const gchar* font_str, gboolean save);
-void stickynote_set_locked(StickyNote *note, gboolean locked);
-void stickynote_set_visible(StickyNote *note, gboolean visible);
-
-void stickynote_change_properties(StickyNote *note);
-
-void stickynotes_add(GdkScreen *screen);
-void stickynotes_remove(StickyNote *note);
-void stickynotes_save(void);
+ const gchar *color_str,
+ const gchar *font_color_str,
+ gboolean save);
+void stickynote_set_font (StickyNote *note,
+ const gchar *font_str,
+ gboolean save);
+void stickynote_set_locked (StickyNote *note,
+ gboolean locked);
+void stickynote_set_visible (StickyNote *note,
+ gboolean visible);
+
+void stickynote_change_properties (StickyNote *note);
+
+void stickynotes_add (GdkScreen *screen);
+void stickynotes_remove (StickyNote *note);
+void stickynotes_save (void);
gboolean stickynotes_save_now (void);
-void stickynotes_load(GdkScreen *screen);
+void stickynotes_load (GdkScreen *screen);
#endif /* __STICKYNOTES_H__ */
diff --git a/stickynotes/stickynotes_applet.c b/stickynotes/stickynotes_applet.c
index 9cc5ebdf..c697151e 100644
--- a/stickynotes/stickynotes_applet.c
+++ b/stickynotes/stickynotes_applet.c
@@ -31,595 +31,624 @@ StickyNotes *stickynotes = NULL;
/* Popup menu on the applet */
static const GtkActionEntry stickynotes_applet_menu_actions[] =
{
- { "new_note", "document-new", N_("_New Note"),
- NULL, NULL,
- G_CALLBACK (menu_new_note_cb) },
- { "hide_notes", NULL, N_("Hi_de Notes"),
- NULL, NULL,
- G_CALLBACK (menu_hide_notes_cb) },
- { "destroy_all", "edit-delete", N_("_Delete Notes"),
- NULL, NULL,
- G_CALLBACK (menu_destroy_all_cb) },
- { "preferences", "document-properties", N_("_Preferences"),
- NULL, NULL,
- G_CALLBACK (menu_preferences_cb) },
- { "help", "help-browser", N_("_Help"),
- NULL, NULL,
- G_CALLBACK (menu_help_cb) },
- { "about", "help-about", N_("_About"),
- NULL, NULL,
- G_CALLBACK (menu_about_cb) }
+ { "new_note", "document-new", N_("_New Note"),
+ NULL, NULL,
+ G_CALLBACK (menu_new_note_cb) },
+ { "hide_notes", NULL, N_("Hi_de Notes"),
+ NULL, NULL,
+ G_CALLBACK (menu_hide_notes_cb) },
+ { "destroy_all", "edit-delete", N_("_Delete Notes"),
+ NULL, NULL,
+ G_CALLBACK (menu_destroy_all_cb) },
+ { "preferences", "document-properties", N_("_Preferences"),
+ NULL, NULL,
+ G_CALLBACK (menu_preferences_cb) },
+ { "help", "help-browser", N_("_Help"),
+ NULL, NULL,
+ G_CALLBACK (menu_help_cb) },
+ { "about", "help-about", N_("_About"),
+ NULL, NULL,
+ G_CALLBACK (menu_about_cb) }
};
static const GtkToggleActionEntry stickynotes_applet_menu_toggle_actions[] =
{
- { "lock", NULL, N_("_Lock Notes"),
- NULL, NULL,
- G_CALLBACK (menu_toggle_lock_cb), FALSE }
+ { "lock", NULL, N_("_Lock Notes"),
+ NULL, NULL,
+ G_CALLBACK (menu_toggle_lock_cb), FALSE }
};
/* Sticky Notes applet factory */
-static gboolean stickynotes_applet_factory(MatePanelApplet *mate_panel_applet, const gchar *iid, gpointer data)
+static gboolean
+stickynotes_applet_factory (MatePanelApplet *mate_panel_applet,
+ const gchar *iid,
+ gpointer data)
{
- if (!strcmp(iid, "StickyNotesApplet")) {
- if (!stickynotes)
- stickynotes_applet_init (mate_panel_applet);
+ if (!strcmp (iid, "StickyNotesApplet")) {
+ if (!stickynotes)
+ stickynotes_applet_init (mate_panel_applet);
- mate_panel_applet_set_flags (mate_panel_applet, MATE_PANEL_APPLET_EXPAND_MINOR);
+ mate_panel_applet_set_flags (mate_panel_applet, MATE_PANEL_APPLET_EXPAND_MINOR);
- /* Add applet to linked list of all applets */
- stickynotes->applets = g_list_append (stickynotes->applets, stickynotes_applet_new(mate_panel_applet));
+ /* Add applet to linked list of all applets */
+ stickynotes->applets = g_list_append (stickynotes->applets,
+ stickynotes_applet_new (mate_panel_applet));
- stickynotes_applet_update_menus ();
- stickynotes_applet_update_tooltips ();
+ stickynotes_applet_update_menus ();
+ stickynotes_applet_update_tooltips ();
- return TRUE;
- }
+ return TRUE;
+ }
- return FALSE;
+ return FALSE;
}
/* Sticky Notes applet factory */
-MATE_PANEL_APPLET_OUT_PROCESS_FACTORY("StickyNotesAppletFactory", PANEL_TYPE_APPLET, "stickynotes_applet",
- stickynotes_applet_factory, NULL)
+MATE_PANEL_APPLET_OUT_PROCESS_FACTORY ("StickyNotesAppletFactory",
+ PANEL_TYPE_APPLET,
+ "stickynotes_applet",
+ stickynotes_applet_factory,
+ NULL)
/* colorshift a surface */
static void
-stickynotes_make_prelight_icon (cairo_surface_t *dest, cairo_surface_t *src, int shift)
+stickynotes_make_prelight_icon (cairo_surface_t *dest,
+ cairo_surface_t *src,
+ int shift)
{
- gint i, j;
- gint width, height, has_alpha, srcrowstride, destrowstride;
- guchar *target_pixels;
- guchar *original_pixels;
- guchar *pixsrc;
- guchar *pixdest;
- int val;
- guchar r,g,b;
-
- has_alpha = cairo_surface_get_content (src) != CAIRO_CONTENT_COLOR;
- width = cairo_image_surface_get_width (src);
- height = cairo_image_surface_get_height (src);
- srcrowstride = cairo_image_surface_get_stride (src);
- destrowstride = cairo_image_surface_get_stride (dest);
- original_pixels = cairo_image_surface_get_data (src);
- target_pixels = cairo_image_surface_get_data (dest);
-
- for (i = 0; i < height; i++) {
- pixdest = target_pixels + i*destrowstride;
- pixsrc = original_pixels + i*srcrowstride;
- for (j = 0; j < width; j++) {
- r = *(pixsrc++);
- g = *(pixsrc++);
- b = *(pixsrc++);
- val = r + shift;
- *(pixdest++) = CLAMP(val, 0, 255);
- val = g + shift;
- *(pixdest++) = CLAMP(val, 0, 255);
- val = b + shift;
- *(pixdest++) = CLAMP(val, 0, 255);
- if (has_alpha)
- *(pixdest++) = *(pixsrc++);
- }
- }
+ gint i, j;
+ gint width, height, has_alpha, srcrowstride, destrowstride;
+ guchar *target_pixels;
+ guchar *original_pixels;
+ guchar *pixsrc;
+ guchar *pixdest;
+ int val;
+ guchar r,g,b;
+
+ has_alpha = cairo_surface_get_content (src) != CAIRO_CONTENT_COLOR;
+ width = cairo_image_surface_get_width (src);
+ height = cairo_image_surface_get_height (src);
+ srcrowstride = cairo_image_surface_get_stride (src);
+ destrowstride = cairo_image_surface_get_stride (dest);
+ original_pixels = cairo_image_surface_get_data (src);
+ target_pixels = cairo_image_surface_get_data (dest);
+
+ for (i = 0; i < height; i++) {
+ pixdest = target_pixels + i*destrowstride;
+ pixsrc = original_pixels + i*srcrowstride;
+ for (j = 0; j < width; j++) {
+ r = *(pixsrc++);
+ g = *(pixsrc++);
+ b = *(pixsrc++);
+ val = r + shift;
+ *(pixdest++) = CLAMP (val, 0, 255);
+ val = g + shift;
+ *(pixdest++) = CLAMP (val, 0, 255);
+ val = b + shift;
+ *(pixdest++) = CLAMP (val, 0, 255);
+ if (has_alpha)
+ *(pixdest++) = *(pixsrc++);
+ }
+ }
}
static void
icon_theme_changed (GtkIconTheme *icon_theme,
gpointer user_data)
{
- gtk_icon_theme_append_search_path (icon_theme,
- PKG_DATA_DIR G_DIR_SEPARATOR_S "icons");
+ gtk_icon_theme_append_search_path (icon_theme,
+ PKG_DATA_DIR G_DIR_SEPARATOR_S "icons");
}
static void
stickynotes_applet_init_icons (void)
{
- GtkIconTheme *icon_theme;
+ GtkIconTheme *icon_theme;
- icon_theme = gtk_icon_theme_get_default ();
- icon_theme_changed (icon_theme, NULL);
+ icon_theme = gtk_icon_theme_get_default ();
+ icon_theme_changed (icon_theme, NULL);
- g_signal_connect (gtk_icon_theme_get_default (), "changed",
- G_CALLBACK (icon_theme_changed), NULL);
+ g_signal_connect (gtk_icon_theme_get_default (), "changed",
+ G_CALLBACK (icon_theme_changed), NULL);
}
static void
stickynotes_destroy (GtkWidget *widget,
gpointer user_dta)
{
- g_signal_handlers_disconnect_by_func (gtk_icon_theme_get_default (),
- icon_theme_changed, NULL);
+ g_signal_handlers_disconnect_by_func (gtk_icon_theme_get_default (),
+ icon_theme_changed, NULL);
}
/* Create and initalize global sticky notes instance */
void
stickynotes_applet_init (MatePanelApplet *mate_panel_applet)
{
- cairo_t *cr;
- gint size, scale;
+ cairo_t *cr;
+ gint size, scale;
- stickynotes = g_new(StickyNotes, 1);
+ stickynotes = g_new (StickyNotes, 1);
- stickynotes->notes = NULL;
- stickynotes->applets = NULL;
- stickynotes->last_timeout_data = 0;
+ stickynotes->notes = NULL;
+ stickynotes->applets = NULL;
+ stickynotes->last_timeout_data = 0;
- size = mate_panel_applet_get_size (mate_panel_applet);
- scale = gtk_widget_get_scale_factor (GTK_WIDGET (mate_panel_applet));
+ size = mate_panel_applet_get_size (mate_panel_applet);
+ scale = gtk_widget_get_scale_factor (GTK_WIDGET (mate_panel_applet));
- g_set_application_name (_("Sticky Notes"));
- gtk_window_set_default_icon_name ("mate-sticky-notes-applet");
+ g_set_application_name (_("Sticky Notes"));
+ gtk_window_set_default_icon_name ("mate-sticky-notes-applet");
- stickynotes->icon_normal = gtk_icon_theme_load_surface (
- gtk_icon_theme_get_default (),
- "mate-sticky-notes-applet",
- size, scale, NULL, 0, NULL);
+ stickynotes->icon_normal =
+ gtk_icon_theme_load_surface (gtk_icon_theme_get_default (),
+ "mate-sticky-notes-applet",
+ size, scale, NULL, 0, NULL);
- stickynotes->icon_prelight = cairo_surface_create_similar (stickynotes->icon_normal,
- cairo_surface_get_content (stickynotes->icon_normal),
- cairo_image_surface_get_width (stickynotes->icon_normal),
- cairo_image_surface_get_height (stickynotes->icon_normal));
+ stickynotes->icon_prelight =
+ cairo_surface_create_similar (stickynotes->icon_normal,
+ cairo_surface_get_content (stickynotes->icon_normal),
+ cairo_image_surface_get_width (stickynotes->icon_normal),
+ cairo_image_surface_get_height (stickynotes->icon_normal));
- stickynotes_make_prelight_icon (stickynotes->icon_prelight, stickynotes->icon_normal, 30);
+ stickynotes_make_prelight_icon (stickynotes->icon_prelight,
+ stickynotes->icon_normal, 30);
- cr = cairo_create (stickynotes->icon_prelight);
- cairo_set_operator (cr, CAIRO_OPERATOR_DEST_IN);
- cairo_mask_surface (cr, stickynotes->icon_normal, 0, 0);
+ cr = cairo_create (stickynotes->icon_prelight);
+ cairo_set_operator (cr, CAIRO_OPERATOR_DEST_IN);
+ cairo_mask_surface (cr, stickynotes->icon_normal, 0, 0);
- stickynotes->settings = g_settings_new (STICKYNOTES_SCHEMA);
- stickynotes->visible = TRUE;
+ stickynotes->settings = g_settings_new (STICKYNOTES_SCHEMA);
+ stickynotes->visible = TRUE;
- stickynotes_applet_init_icons();
- stickynotes_applet_init_prefs();
+ stickynotes_applet_init_icons ();
+ stickynotes_applet_init_prefs ();
- /* Watch GSettings values */
- g_signal_connect (stickynotes->settings, "changed",
- G_CALLBACK (preferences_apply_cb), NULL);
+ /* Watch GSettings values */
+ g_signal_connect (stickynotes->settings, "changed",
+ G_CALLBACK (preferences_apply_cb), NULL);
- /* Max height for large notes*/
- stickynotes->max_height = 0.8 * HeightOfScreen (gdk_x11_screen_get_xscreen (gdk_screen_get_default ()));
+ /* Max height for large notes*/
+ stickynotes->max_height =
+ 0.8 * HeightOfScreen (gdk_x11_screen_get_xscreen (gdk_screen_get_default ()));
- /* Load sticky notes */
- stickynotes_load (gtk_widget_get_screen (GTK_WIDGET (mate_panel_applet)));
+ /* Load sticky notes */
+ stickynotes_load (gtk_widget_get_screen (GTK_WIDGET (mate_panel_applet)));
- install_check_click_on_desktop ();
+ install_check_click_on_desktop ();
}
-void stickynotes_applet_init_prefs(void)
+void
+stickynotes_applet_init_prefs (void)
{
- stickynotes->builder = gtk_builder_new ();
-
- gtk_builder_add_from_resource (stickynotes->builder, GRESOURCE "sticky-notes-preferences.ui", NULL);
-
- stickynotes->w_prefs = GTK_WIDGET (gtk_builder_get_object (stickynotes->builder,
- "preferences_dialog"));
-
- stickynotes->w_prefs_width = gtk_spin_button_get_adjustment (
- GTK_SPIN_BUTTON (gtk_builder_get_object (
- stickynotes->builder, "width_spin")));
- stickynotes->w_prefs_height = gtk_spin_button_get_adjustment (
- GTK_SPIN_BUTTON (gtk_builder_get_object (
- stickynotes->builder, "height_spin")));
- stickynotes->w_prefs_color = GTK_WIDGET (gtk_builder_get_object (stickynotes->builder,
- "default_color"));
- stickynotes->w_prefs_font_color = GTK_WIDGET (gtk_builder_get_object (stickynotes->builder,
- "prefs_font_color"));
- stickynotes->w_prefs_sys_color = GTK_WIDGET (&GTK_CHECK_BUTTON (
- gtk_builder_get_object (stickynotes->builder,
- "sys_color_check"))->toggle_button);
- stickynotes->w_prefs_font = GTK_WIDGET (gtk_builder_get_object (stickynotes->builder,
- "default_font"));
- stickynotes->w_prefs_sys_font = GTK_WIDGET (&GTK_CHECK_BUTTON (
- gtk_builder_get_object (stickynotes->builder,
- "sys_font_check"))->toggle_button);
- stickynotes->w_prefs_sticky = GTK_WIDGET (&GTK_CHECK_BUTTON (
- gtk_builder_get_object (stickynotes->builder,
- "sticky_check"))->toggle_button);
- stickynotes->w_prefs_force = GTK_WIDGET (&GTK_CHECK_BUTTON (
- gtk_builder_get_object (stickynotes->builder,
- "force_default_check"))->toggle_button);
- stickynotes->w_prefs_desktop = GTK_WIDGET (&GTK_CHECK_BUTTON (
- gtk_builder_get_object (stickynotes->builder,
- "desktop_hide_check"))->toggle_button);
-
- g_signal_connect (G_OBJECT (stickynotes->w_prefs), "response",
- G_CALLBACK (preferences_response_cb), NULL);
- g_signal_connect (G_OBJECT (stickynotes->w_prefs), "delete-event",
- G_CALLBACK (preferences_delete_cb), NULL);
- g_signal_connect_swapped (G_OBJECT (stickynotes->w_prefs_width),
- "value-changed",
- G_CALLBACK (preferences_save_cb), NULL);
- g_signal_connect_swapped (G_OBJECT (stickynotes->w_prefs_height),
- "value-changed",
- G_CALLBACK (preferences_save_cb), NULL);
- g_signal_connect_swapped (G_OBJECT (stickynotes->w_prefs_sys_color),
- "toggled",
- G_CALLBACK (preferences_save_cb), NULL);
- g_signal_connect_swapped (G_OBJECT(stickynotes->w_prefs_sys_font),
- "toggled", G_CALLBACK (preferences_save_cb), NULL);
- g_signal_connect (G_OBJECT (stickynotes->w_prefs_color),
- "color-set", G_CALLBACK (preferences_color_cb), NULL);
- g_signal_connect (G_OBJECT (stickynotes->w_prefs_font_color),
- "color-set", G_CALLBACK (preferences_color_cb), NULL);
- g_signal_connect (G_OBJECT (stickynotes->w_prefs_font),
- "font-set", G_CALLBACK (preferences_font_cb), NULL);
- g_signal_connect_swapped (G_OBJECT (stickynotes->w_prefs_sticky),
- "toggled", G_CALLBACK (preferences_save_cb), NULL);
- g_signal_connect_swapped (G_OBJECT (stickynotes->w_prefs_force),
- "toggled", G_CALLBACK (preferences_save_cb), NULL);
- g_signal_connect_swapped (G_OBJECT (stickynotes->w_prefs_desktop),
- "toggled", G_CALLBACK (preferences_save_cb), NULL);
-
- {
- GtkSizeGroup *group = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
-
- gtk_size_group_add_widget(group, GTK_WIDGET (gtk_builder_get_object (stickynotes->builder, "width_label")));
- gtk_size_group_add_widget(group, GTK_WIDGET (gtk_builder_get_object (stickynotes->builder, "height_label")));
- gtk_size_group_add_widget(group, GTK_WIDGET (gtk_builder_get_object (stickynotes->builder, "prefs_color_label")));
-
- g_object_unref(group);
- }
-
- if (!g_settings_is_writable (stickynotes->settings, "default-width"))
- {
- gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (
- stickynotes->builder, "width_label")),
- FALSE);
- gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (
- stickynotes->builder, "width_spin")),
- FALSE);
- }
- if (!g_settings_is_writable (stickynotes->settings, "default-height"))
- {
- gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (
- stickynotes->builder, "height_label")),
- FALSE);
- gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (
- stickynotes->builder, "height_spin")),
- FALSE);
- }
- if (!g_settings_is_writable (stickynotes->settings, "default-color"))
- {
- gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (
- stickynotes->builder, "prefs_color_label")),
- FALSE);
- gtk_widget_set_sensitive (stickynotes->w_prefs_color, FALSE);
- }
- if (!g_settings_is_writable (stickynotes->settings, "default-font-color"))
- {
- gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (
- stickynotes->builder, "prefs_font_color_label")),
- FALSE);
- gtk_widget_set_sensitive (stickynotes->w_prefs_font_color,
- FALSE);
- }
- if (!g_settings_is_writable (stickynotes->settings, "use-system-color"))
- gtk_widget_set_sensitive (stickynotes->w_prefs_sys_color,
- FALSE);
- if (!g_settings_is_writable (stickynotes->settings, "default-font"))
- {
- gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (
- stickynotes->builder, "prefs_font_label")),
- FALSE);
- gtk_widget_set_sensitive (stickynotes->w_prefs_font, FALSE);
- }
- if (!g_settings_is_writable (stickynotes->settings, "use-system-font"))
- gtk_widget_set_sensitive (stickynotes->w_prefs_sys_font,
- FALSE);
- if (!g_settings_is_writable (stickynotes->settings, "sticky"))
- 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);
-
- stickynotes_applet_update_prefs();
+ stickynotes->builder = gtk_builder_new ();
+
+ gtk_builder_add_from_resource (stickynotes->builder,
+ GRESOURCE "sticky-notes-preferences.ui",
+ NULL);
+
+ stickynotes->w_prefs =
+ GTK_WIDGET (gtk_builder_get_object (stickynotes->builder,
+ "preferences_dialog"));
+
+ stickynotes->w_prefs_width =
+ gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (gtk_builder_get_object (stickynotes->builder,
+ "width_spin")));
+ stickynotes->w_prefs_height =
+ gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (gtk_builder_get_object (stickynotes->builder,
+ "height_spin")));
+ stickynotes->w_prefs_color =
+ GTK_WIDGET (gtk_builder_get_object (stickynotes->builder,
+ "default_color"));
+ stickynotes->w_prefs_font_color =
+ GTK_WIDGET (gtk_builder_get_object (stickynotes->builder,
+ "prefs_font_color"));
+ stickynotes->w_prefs_sys_color =
+ GTK_WIDGET (&GTK_CHECK_BUTTON (gtk_builder_get_object (stickynotes->builder,
+ "sys_color_check"))->toggle_button);
+ stickynotes->w_prefs_font =
+ GTK_WIDGET (gtk_builder_get_object (stickynotes->builder,
+ "default_font"));
+ stickynotes->w_prefs_sys_font =
+ GTK_WIDGET (&GTK_CHECK_BUTTON (gtk_builder_get_object (stickynotes->builder,
+ "sys_font_check"))->toggle_button);
+ stickynotes->w_prefs_sticky =
+ GTK_WIDGET (&GTK_CHECK_BUTTON (gtk_builder_get_object (stickynotes->builder,
+ "sticky_check"))->toggle_button);
+ stickynotes->w_prefs_force =
+ GTK_WIDGET (&GTK_CHECK_BUTTON (gtk_builder_get_object (stickynotes->builder,
+ "force_default_check"))->toggle_button);
+ stickynotes->w_prefs_desktop =
+ GTK_WIDGET (&GTK_CHECK_BUTTON (gtk_builder_get_object (stickynotes->builder,
+ "desktop_hide_check"))->toggle_button);
+
+ g_signal_connect (stickynotes->w_prefs, "response",
+ G_CALLBACK (preferences_response_cb), NULL);
+ g_signal_connect (stickynotes->w_prefs, "delete-event",
+ G_CALLBACK (preferences_delete_cb), NULL);
+ g_signal_connect_swapped (stickynotes->w_prefs_width, "value-changed",
+ G_CALLBACK (preferences_save_cb), NULL);
+ g_signal_connect_swapped (stickynotes->w_prefs_height, "value-changed",
+ G_CALLBACK (preferences_save_cb), NULL);
+ g_signal_connect_swapped (stickynotes->w_prefs_sys_color, "toggled",
+ G_CALLBACK (preferences_save_cb), NULL);
+ g_signal_connect_swapped (stickynotes->w_prefs_sys_font, "toggled",
+ G_CALLBACK (preferences_save_cb), NULL);
+ g_signal_connect (stickynotes->w_prefs_color, "color-set",
+ G_CALLBACK (preferences_color_cb), NULL);
+ g_signal_connect (stickynotes->w_prefs_font_color, "color-set",
+ G_CALLBACK (preferences_color_cb), NULL);
+ g_signal_connect (stickynotes->w_prefs_font, "font-set",
+ G_CALLBACK (preferences_font_cb), NULL);
+ g_signal_connect_swapped (stickynotes->w_prefs_sticky, "toggled",
+ G_CALLBACK (preferences_save_cb), NULL);
+ g_signal_connect_swapped (stickynotes->w_prefs_force, "toggled",
+ G_CALLBACK (preferences_save_cb), NULL);
+ g_signal_connect_swapped (stickynotes->w_prefs_desktop, "toggled",
+ G_CALLBACK (preferences_save_cb), NULL);
+
+ {
+ GtkSizeGroup *group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
+
+ gtk_size_group_add_widget (group,
+ GTK_WIDGET (gtk_builder_get_object (stickynotes->builder,
+ "width_label")));
+ gtk_size_group_add_widget (group,
+ GTK_WIDGET (gtk_builder_get_object (stickynotes->builder,
+ "height_label")));
+ gtk_size_group_add_widget (group,
+ GTK_WIDGET (gtk_builder_get_object (stickynotes->builder,
+ "prefs_color_label")));
+
+ g_object_unref (group);
+ }
+
+ if (!g_settings_is_writable (stickynotes->settings, "default-width")) {
+ gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (stickynotes->builder,
+ "width_label")),
+ FALSE);
+ gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (stickynotes->builder,
+ "width_spin")),
+ FALSE);
+ }
+ if (!g_settings_is_writable (stickynotes->settings, "default-height")) {
+ gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (stickynotes->builder,
+ "height_label")),
+ FALSE);
+ gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (stickynotes->builder,
+ "height_spin")),
+ FALSE);
+ }
+ if (!g_settings_is_writable (stickynotes->settings, "default-color")) {
+ gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (stickynotes->builder,
+ "prefs_color_label")),
+ FALSE);
+ gtk_widget_set_sensitive (stickynotes->w_prefs_color, FALSE);
+ }
+ if (!g_settings_is_writable (stickynotes->settings, "default-font-color")) {
+ gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (stickynotes->builder,
+ "prefs_font_color_label")),
+ FALSE);
+ gtk_widget_set_sensitive (stickynotes->w_prefs_font_color, FALSE);
+ }
+ if (!g_settings_is_writable (stickynotes->settings, "use-system-color"))
+ gtk_widget_set_sensitive (stickynotes->w_prefs_sys_color, FALSE);
+ if (!g_settings_is_writable (stickynotes->settings, "default-font")) {
+ gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (stickynotes->builder,
+ "prefs_font_label")),
+ FALSE);
+ gtk_widget_set_sensitive (stickynotes->w_prefs_font, FALSE);
+ }
+ if (!g_settings_is_writable (stickynotes->settings, "use-system-font"))
+ gtk_widget_set_sensitive (stickynotes->w_prefs_sys_font, FALSE);
+ if (!g_settings_is_writable (stickynotes->settings, "sticky"))
+ 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);
+
+ stickynotes_applet_update_prefs ();
}
/* Create a Sticky Notes applet */
StickyNotesApplet *
-stickynotes_applet_new(MatePanelApplet *mate_panel_applet)
+stickynotes_applet_new (MatePanelApplet *mate_panel_applet)
{
- AtkObject *atk_obj;
-
- /* Create Sticky Notes Applet */
- StickyNotesApplet *applet = g_new(StickyNotesApplet, 1);
-
- /* Initialize Sticky Notes Applet */
- applet->w_applet = GTK_WIDGET(mate_panel_applet);
- applet->w_image = gtk_image_new();
- applet->destroy_all_dialog = NULL;
- applet->prelighted = FALSE;
-
- applet->menu_tip = NULL;
-
- /* Expand the applet for Fitts' law complience. */
- mate_panel_applet_set_flags(mate_panel_applet, MATE_PANEL_APPLET_EXPAND_MINOR);
-
- /* Add the applet icon */
- gtk_container_add(GTK_CONTAINER(mate_panel_applet), applet->w_image);
- applet->panel_size = mate_panel_applet_get_size (mate_panel_applet);
- applet->panel_orient = mate_panel_applet_get_orient (mate_panel_applet);
- stickynotes_applet_update_icon(applet);
-
- /* Add the popup menu */
- applet->action_group = gtk_action_group_new ("StickyNotes Applet Actions");
- gtk_action_group_set_translation_domain (applet->action_group, GETTEXT_PACKAGE);
- gtk_action_group_add_actions (applet->action_group,
- stickynotes_applet_menu_actions,
- G_N_ELEMENTS (stickynotes_applet_menu_actions),
- applet);
- gtk_action_group_add_toggle_actions (applet->action_group,
- stickynotes_applet_menu_toggle_actions,
- G_N_ELEMENTS (stickynotes_applet_menu_toggle_actions),
- applet);
- mate_panel_applet_setup_menu_from_resource (mate_panel_applet,
- GRESOURCE "menu.xml",
- applet->action_group);
-
- if (mate_panel_applet_get_locked_down (mate_panel_applet)) {
- GtkAction *action;
-
- action = gtk_action_group_get_action (applet->action_group, "preferences");
- gtk_action_set_visible (action, FALSE);
- }
-
- /* Connect all signals for applet management */
- g_signal_connect(G_OBJECT(applet->w_applet), "button-press-event",
- G_CALLBACK(applet_button_cb), applet);
- g_signal_connect(G_OBJECT(applet->w_applet), "key-press-event",
- G_CALLBACK(applet_key_cb), applet);
- g_signal_connect(G_OBJECT(applet->w_applet), "focus-in-event",
- G_CALLBACK(applet_focus_cb), applet);
- g_signal_connect(G_OBJECT(applet->w_applet), "focus-out-event",
- G_CALLBACK(applet_focus_cb), applet);
- g_signal_connect(G_OBJECT(applet->w_applet), "enter-notify-event",
- G_CALLBACK(applet_cross_cb), applet);
- g_signal_connect(G_OBJECT(applet->w_applet), "leave-notify-event",
- G_CALLBACK(applet_cross_cb), applet);
- g_signal_connect(G_OBJECT(applet->w_applet), "size-allocate",
- G_CALLBACK(applet_size_allocate_cb), applet);
- g_signal_connect(G_OBJECT(applet->w_applet), "change-orient",
- G_CALLBACK(applet_change_orient_cb), applet);
- g_signal_connect(G_OBJECT(applet->w_applet), "destroy",
- G_CALLBACK(applet_destroy_cb), applet);
- g_signal_connect(G_OBJECT(applet->w_applet), "destroy",
- G_CALLBACK(stickynotes_destroy), NULL);
-
- atk_obj = gtk_widget_get_accessible (applet->w_applet);
- atk_object_set_name (atk_obj, _("Sticky Notes"));
-
- /* Show the applet */
- gtk_widget_show_all(GTK_WIDGET(applet->w_applet));
-
- return applet;
+ AtkObject *atk_obj;
+
+ /* Create Sticky Notes Applet */
+ StickyNotesApplet *applet = g_new (StickyNotesApplet, 1);
+
+ /* Initialize Sticky Notes Applet */
+ applet->w_applet = GTK_WIDGET (mate_panel_applet);
+ applet->w_image = gtk_image_new ();
+ applet->destroy_all_dialog = NULL;
+ applet->prelighted = FALSE;
+
+ applet->menu_tip = NULL;
+
+ /* Expand the applet for Fitts' law complience. */
+ mate_panel_applet_set_flags (mate_panel_applet,
+ MATE_PANEL_APPLET_EXPAND_MINOR);
+
+ /* Add the applet icon */
+ gtk_container_add (GTK_CONTAINER (mate_panel_applet),
+ applet->w_image);
+ applet->panel_size = mate_panel_applet_get_size (mate_panel_applet);
+ applet->panel_orient = mate_panel_applet_get_orient (mate_panel_applet);
+ stickynotes_applet_update_icon (applet);
+
+ /* Add the popup menu */
+ applet->action_group = gtk_action_group_new ("StickyNotes Applet Actions");
+ gtk_action_group_set_translation_domain (applet->action_group,
+ GETTEXT_PACKAGE);
+ gtk_action_group_add_actions (applet->action_group,
+ stickynotes_applet_menu_actions,
+ G_N_ELEMENTS (stickynotes_applet_menu_actions),
+ applet);
+ gtk_action_group_add_toggle_actions (applet->action_group,
+ stickynotes_applet_menu_toggle_actions,
+ G_N_ELEMENTS (stickynotes_applet_menu_toggle_actions),
+ applet);
+ mate_panel_applet_setup_menu_from_resource (mate_panel_applet,
+ GRESOURCE "menu.xml",
+ applet->action_group);
+
+ if (mate_panel_applet_get_locked_down (mate_panel_applet)) {
+ GtkAction *action;
+
+ action = gtk_action_group_get_action (applet->action_group,
+ "preferences");
+ gtk_action_set_visible (action, FALSE);
+ }
+
+ /* Connect all signals for applet management */
+ g_signal_connect (applet->w_applet, "button-press-event",
+ G_CALLBACK (applet_button_cb), applet);
+ g_signal_connect (applet->w_applet, "key-press-event",
+ G_CALLBACK (applet_key_cb), applet);
+ g_signal_connect (applet->w_applet, "focus-in-event",
+ G_CALLBACK (applet_focus_cb), applet);
+ g_signal_connect (applet->w_applet, "focus-out-event",
+ G_CALLBACK (applet_focus_cb), applet);
+ g_signal_connect (applet->w_applet, "enter-notify-event",
+ G_CALLBACK (applet_cross_cb), applet);
+ g_signal_connect (applet->w_applet, "leave-notify-event",
+ G_CALLBACK (applet_cross_cb), applet);
+ g_signal_connect (applet->w_applet, "size-allocate",
+ G_CALLBACK (applet_size_allocate_cb), applet);
+ g_signal_connect (applet->w_applet, "change-orient",
+ G_CALLBACK (applet_change_orient_cb), applet);
+ g_signal_connect (applet->w_applet, "destroy",
+ G_CALLBACK (applet_destroy_cb), applet);
+ g_signal_connect (applet->w_applet, "destroy",
+ G_CALLBACK (stickynotes_destroy), NULL);
+
+ atk_obj = gtk_widget_get_accessible (applet->w_applet);
+ atk_object_set_name (atk_obj, _("Sticky Notes"));
+
+ /* Show the applet */
+ gtk_widget_show_all (applet->w_applet);
+
+ return applet;
}
-void stickynotes_applet_update_icon(StickyNotesApplet *applet)
+void
+stickynotes_applet_update_icon (StickyNotesApplet *applet)
{
- cairo_t *cr;
- cairo_surface_t *surface;
+ cairo_t *cr;
+ cairo_surface_t *surface;
- gint size = applet->panel_size;
+ gint size = applet->panel_size;
- if (size > 3)
- size = size - 3;
+ if (size > 3)
+ size = size - 3;
- /* Choose appropriate icon and size it */
- if (applet->prelighted)
- surface = cairo_surface_create_similar (stickynotes->icon_prelight,
- cairo_surface_get_content (stickynotes->icon_prelight),
- size, size);
- else
- surface = cairo_surface_create_similar (stickynotes->icon_normal,
- cairo_surface_get_content (stickynotes->icon_normal),
- size, size);
+ /* Choose appropriate icon and size it */
+ if (applet->prelighted)
+ surface = cairo_surface_create_similar (stickynotes->icon_prelight,
+ cairo_surface_get_content (stickynotes->icon_prelight),
+ size, size);
+ else
+ surface = cairo_surface_create_similar (stickynotes->icon_normal,
+ cairo_surface_get_content (stickynotes->icon_normal),
+ size, size);
- cr = cairo_create (surface);
- cairo_set_source_surface (cr, applet->prelighted ? stickynotes->icon_prelight : stickynotes->icon_normal, 0, 0);
- cairo_paint (cr);
+ cr = cairo_create (surface);
+ cairo_set_source_surface (cr, applet->prelighted ? stickynotes->icon_prelight : stickynotes->icon_normal, 0, 0);
+ cairo_paint (cr);
- /* Apply the finished surface to the applet image */
- gtk_image_set_from_surface(GTK_IMAGE(applet->w_image), surface);
+ /* Apply the finished surface to the applet image */
+ gtk_image_set_from_surface (GTK_IMAGE (applet->w_image), surface);
- cairo_surface_destroy(surface);
+ cairo_surface_destroy (surface);
}
void
stickynotes_applet_update_prefs (void)
{
- gint width, height;
- gboolean sys_color, sys_font, sticky, force_default, desktop_hide;
- char *font_str;
- char *color_str, *font_color_str;
- GdkRGBA color, font_color;
-
- width = g_settings_get_int (stickynotes->settings, "default-width");
- width = MAX (width, 1);
- height = g_settings_get_int (stickynotes->settings, "default-height");
- height = MAX (height, 1);
-
- sys_color = g_settings_get_boolean (stickynotes->settings, "use-system-color");
- sys_font = g_settings_get_boolean (stickynotes->settings, "use-system-font");
- sticky = g_settings_get_boolean (stickynotes->settings, "sticky");
- force_default = g_settings_get_boolean (stickynotes->settings, "force-default");
- desktop_hide = g_settings_get_boolean (stickynotes->settings, "desktop-hide");
-
- font_str = g_settings_get_string (stickynotes->settings, "default-font");
- if (!font_str)
- {
- font_str = g_strdup ("Sans 10");
- }
-
- color_str = g_settings_get_string (stickynotes->settings, "default-color");
- if (!color_str)
- {
- color_str = g_strdup ("#ECF833");
- }
- font_color_str = g_settings_get_string (stickynotes->settings, "default-font-color");
- if (!font_color_str)
- {
- font_color_str = g_strdup ("#000000");
- }
-
- gdk_rgba_parse (&color, color_str);
- gdk_rgba_parse (&font_color, font_color_str);
-
- g_free (color_str);
- g_free (font_color_str);
-
- gtk_adjustment_set_value (stickynotes->w_prefs_width, width);
- gtk_adjustment_set_value (stickynotes->w_prefs_height, height);
- gtk_toggle_button_set_active (
- GTK_TOGGLE_BUTTON (stickynotes->w_prefs_sys_color),
- sys_color);
- gtk_toggle_button_set_active (
- GTK_TOGGLE_BUTTON(stickynotes->w_prefs_sys_font),
- sys_font);
- gtk_toggle_button_set_active (
- GTK_TOGGLE_BUTTON (stickynotes->w_prefs_sticky),
- sticky);
- gtk_toggle_button_set_active (
- GTK_TOGGLE_BUTTON (stickynotes->w_prefs_force),
- force_default);
- gtk_toggle_button_set_active (
- GTK_TOGGLE_BUTTON (stickynotes->w_prefs_desktop),
- desktop_hide);
-
- gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (stickynotes->w_prefs_color), &color);
- gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (stickynotes->w_prefs_font_color), &font_color);
-
- gtk_font_button_set_font_name (GTK_FONT_BUTTON (stickynotes->w_prefs_font), font_str);
- g_free (font_str);
-
- if (g_settings_is_writable (stickynotes->settings, "default-color"))
- {
- gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (
- stickynotes->builder, "prefs_color_label")),
- !sys_color);
- gtk_widget_set_sensitive (stickynotes->w_prefs_color,
- !sys_color);
- }
- if (g_settings_is_writable (stickynotes->settings, "default-font-color"))
- {
- gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (
- stickynotes->builder, "prefs_font_color_label")),
- !sys_color);
- gtk_widget_set_sensitive (stickynotes->w_prefs_font_color,
- !sys_color);
- }
- if (g_settings_is_writable (stickynotes->settings, "default-font"))
- {
- gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (
- stickynotes->builder, "prefs_font_label")),
- !sys_font);
- gtk_widget_set_sensitive (stickynotes->w_prefs_font,
- !sys_font);
- }
+ gint width, height;
+ gboolean sys_color, sys_font, sticky, force_default, desktop_hide;
+ char *font_str;
+ char *color_str, *font_color_str;
+ GdkRGBA color, font_color;
+
+ width = g_settings_get_int (stickynotes->settings,
+ "default-width");
+ width = MAX (width, 1);
+ height = g_settings_get_int (stickynotes->settings,
+ "default-height");
+ height = MAX (height, 1);
+
+ sys_color = g_settings_get_boolean (stickynotes->settings,
+ "use-system-color");
+ sys_font = g_settings_get_boolean (stickynotes->settings,
+ "use-system-font");
+ sticky = g_settings_get_boolean (stickynotes->settings,
+ "sticky");
+ force_default = g_settings_get_boolean (stickynotes->settings,
+ "force-default");
+ desktop_hide = g_settings_get_boolean (stickynotes->settings,
+ "desktop-hide");
+
+ font_str = g_settings_get_string (stickynotes->settings,
+ "default-font");
+ if (!font_str)
+ font_str = g_strdup ("Sans 10");
+
+ color_str = g_settings_get_string (stickynotes->settings,
+ "default-color");
+ if (!color_str)
+ color_str = g_strdup ("#ECF833");
+
+ font_color_str = g_settings_get_string (stickynotes->settings,
+ "default-font-color");
+ if (!font_color_str)
+ font_color_str = g_strdup ("#000000");
+
+ gdk_rgba_parse (&color, color_str);
+ gdk_rgba_parse (&font_color, font_color_str);
+
+ g_free (color_str);
+ g_free (font_color_str);
+
+ gtk_adjustment_set_value (stickynotes->w_prefs_width, width);
+ gtk_adjustment_set_value (stickynotes->w_prefs_height, height);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (stickynotes->w_prefs_sys_color),
+ sys_color);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (stickynotes->w_prefs_sys_font),
+ sys_font);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (stickynotes->w_prefs_sticky),
+ sticky);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (stickynotes->w_prefs_force),
+ force_default);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (stickynotes->w_prefs_desktop),
+ desktop_hide);
+
+ gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (stickynotes->w_prefs_color),
+ &color);
+ gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (stickynotes->w_prefs_font_color),
+ &font_color);
+
+ gtk_font_button_set_font_name (GTK_FONT_BUTTON (stickynotes->w_prefs_font),
+ font_str);
+ g_free (font_str);
+
+ if (g_settings_is_writable (stickynotes->settings, "default-color")) {
+ gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (stickynotes->builder,
+ "prefs_color_label")),
+ !sys_color);
+ gtk_widget_set_sensitive (stickynotes->w_prefs_color, !sys_color);
+ }
+ if (g_settings_is_writable (stickynotes->settings, "default-font-color")) {
+ gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (stickynotes->builder,
+ "prefs_font_color_label")),
+ !sys_color);
+ gtk_widget_set_sensitive (stickynotes->w_prefs_font_color, !sys_color);
+ }
+ if (g_settings_is_writable (stickynotes->settings, "default-font")) {
+ gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (stickynotes->builder,
+ "prefs_font_label")),
+ !sys_font);
+ gtk_widget_set_sensitive (stickynotes->w_prefs_font, !sys_font);
+ }
}
-void stickynotes_applet_update_menus(void)
+void
+stickynotes_applet_update_menus (void)
{
- GList *l;
- gboolean inconsistent = FALSE;
-
- gboolean locked = g_settings_get_boolean (stickynotes->settings, "locked");
- gboolean locked_writable = g_settings_is_writable (stickynotes->settings, "locked");
-
- for (l = stickynotes->notes; l != NULL; l = l->next) {
- StickyNote *note = l->data;
-
- if (note->locked != locked) {
- inconsistent = TRUE;
- break;
- }
- }
-
- for (l = stickynotes->applets; l != NULL; l = l->next) {
- StickyNotesApplet *applet = l->data;
- GSList *proxies, *p;
-
- GtkAction *action = gtk_action_group_get_action (applet->action_group, "lock");
-
- g_object_set (action,
- "active", locked,
- "sensitive", locked_writable,
- NULL);
-
- proxies = gtk_action_get_proxies (action);
- for (p = proxies; p; p = g_slist_next (p)) {
- if (GTK_IS_CHECK_MENU_ITEM (p->data)) {
- gtk_check_menu_item_set_inconsistent (GTK_CHECK_MENU_ITEM (p->data),
- inconsistent);
- }
- }
- }
+ GList *l;
+ gboolean inconsistent = FALSE;
+
+ gboolean locked = g_settings_get_boolean (stickynotes->settings,
+ "locked");
+ gboolean locked_writable = g_settings_is_writable (stickynotes->settings,
+ "locked");
+
+ for (l = stickynotes->notes; l != NULL; l = l->next) {
+ StickyNote *note = l->data;
+
+ if (note->locked != locked) {
+ inconsistent = TRUE;
+ break;
+ }
+ }
+
+ for (l = stickynotes->applets; l != NULL; l = l->next) {
+ StickyNotesApplet *applet = l->data;
+ GSList *proxies, *p;
+
+ GtkAction *action = gtk_action_group_get_action (applet->action_group,
+ "lock");
+
+ g_object_set (action,
+ "active", locked,
+ "sensitive", locked_writable,
+ NULL);
+
+ proxies = gtk_action_get_proxies (action);
+ for (p = proxies; p; p = g_slist_next (p)) {
+ if (GTK_IS_CHECK_MENU_ITEM (p->data))
+ gtk_check_menu_item_set_inconsistent (GTK_CHECK_MENU_ITEM (p->data),
+ inconsistent);
+ }
+ }
}
void
stickynotes_applet_update_tooltips (void)
{
- int num;
- char *tooltip, *no_notes;
- StickyNotesApplet *applet;
- GList *l;
-
- num = g_list_length (stickynotes->notes);
-
- no_notes = g_strdup_printf (ngettext ("%d note", "%d notes", num), num);
- tooltip = g_strdup_printf ("%s\n%s", _("Show sticky notes"), no_notes);
-
- for (l = stickynotes->applets; l; l = l->next)
- {
- applet = l->data;
- gtk_widget_set_tooltip_text (applet->w_applet, tooltip);
-
- if (applet->menu_tip)
- gtk_label_set_text (GTK_LABEL (gtk_bin_get_child (
- GTK_BIN (applet->menu_tip))),
- no_notes);
- }
-
- g_free (tooltip);
- g_free (no_notes);
+ int num;
+ char *tooltip, *no_notes;
+ StickyNotesApplet *applet;
+ GList *l;
+
+ num = g_list_length (stickynotes->notes);
+
+ no_notes = g_strdup_printf (ngettext ("%d note",
+ "%d notes",
+ num),
+ num);
+
+ tooltip = g_strdup_printf ("%s\n%s",
+ _("Show sticky notes"),
+ no_notes);
+
+ for (l = stickynotes->applets; l; l = l->next)
+ {
+ applet = l->data;
+ gtk_widget_set_tooltip_text (applet->w_applet,
+ tooltip);
+
+ if (applet->menu_tip)
+ gtk_label_set_text (GTK_LABEL (gtk_bin_get_child (GTK_BIN (applet->menu_tip))),
+ no_notes);
+ }
+
+ g_free (tooltip);
+ g_free (no_notes);
}
void
-stickynotes_applet_panel_icon_get_geometry (int *x, int *y, int *width, int *height)
+stickynotes_applet_panel_icon_get_geometry (int *x,
+ int *y,
+ int *width,
+ int *height)
{
- GtkWidget *widget;
- GtkAllocation allocation;
- GtkRequisition requisition;
- StickyNotesApplet *applet;
+ GtkWidget *widget;
+ GtkAllocation allocation;
+ GtkRequisition requisition;
+ StickyNotesApplet *applet;
- applet = stickynotes->applets->data;
+ applet = stickynotes->applets->data;
- widget = GTK_WIDGET (applet->w_image);
+ widget = GTK_WIDGET (applet->w_image);
- gtk_widget_get_preferred_size (widget, NULL, &requisition);
+ gtk_widget_get_preferred_size (widget,
+ NULL, &requisition);
- gdk_window_get_origin (gtk_widget_get_window (widget), x, y);
+ gdk_window_get_origin (gtk_widget_get_window (widget), x, y);
- gtk_widget_get_allocation (widget, &allocation);
- *width = allocation.x;
- *height = allocation.y;
+ gtk_widget_get_allocation (widget, &allocation);
+ *width = allocation.x;
+ *height = allocation.y;
}
diff --git a/stickynotes/stickynotes_applet.h b/stickynotes/stickynotes_applet.h
index 4d10c387..072318d3 100644
--- a/stickynotes/stickynotes_applet.h
+++ b/stickynotes/stickynotes_applet.h
@@ -26,85 +26,87 @@
#include <gio/gio.h>
#include <mate-panel-applet.h>
+#define STICKYNOTES_SCHEMA "org.mate.stickynotes"
-#define STICKYNOTES_SCHEMA "org.mate.stickynotes"
-
-#define STICKYNOTES_STOCK_LOCKED "stickynotes-stock-locked"
-#define STICKYNOTES_STOCK_UNLOCKED "stickynotes-stock-unlocked"
-#define STICKYNOTES_STOCK_CLOSE "stickynotes-stock-close"
-#define STICKYNOTES_STOCK_RESIZE_SE "stickynotes-stock-resize-se"
-#define STICKYNOTES_STOCK_RESIZE_SW "stickynotes-stock-resize-sw"
+#define STICKYNOTES_STOCK_LOCKED "stickynotes-stock-locked"
+#define STICKYNOTES_STOCK_UNLOCKED "stickynotes-stock-unlocked"
+#define STICKYNOTES_STOCK_CLOSE "stickynotes-stock-close"
+#define STICKYNOTES_STOCK_RESIZE_SE "stickynotes-stock-resize-se"
+#define STICKYNOTES_STOCK_RESIZE_SW "stickynotes-stock-resize-sw"
/* Global Sticky Notes instance */
typedef struct
{
- GtkBuilder *builder;
-
- GtkWidget *w_prefs; /* The prefs dialog */
- GtkAdjustment *w_prefs_width;
- GtkAdjustment *w_prefs_height;
- GtkWidget *w_prefs_color;
- GtkWidget *w_prefs_font_color;
- GtkWidget *w_prefs_sys_color;
- GtkWidget *w_prefs_font;
- GtkWidget *w_prefs_sys_font;
- GtkWidget *w_prefs_sticky;
- GtkWidget *w_prefs_force;
- GtkWidget *w_prefs_desktop;
-
- GList *notes; /* Linked-List of all the sticky notes */
- GList *applets; /* Linked-List of all the applets */
-
- cairo_surface_t *icon_normal; /* Normal applet icon */
- cairo_surface_t *icon_prelight; /* Prelighted applet icon */
-
- GSettings *settings; /* Shared GSettings */
-
- gint max_height;
- guint last_timeout_data;
-
- gboolean visible; /* Toggle show/hide notes */
+ GtkBuilder *builder;
+
+ GtkWidget *w_prefs; /* The prefs dialog */
+ GtkAdjustment *w_prefs_width;
+ GtkAdjustment *w_prefs_height;
+ GtkWidget *w_prefs_color;
+ GtkWidget *w_prefs_font_color;
+ GtkWidget *w_prefs_sys_color;
+ GtkWidget *w_prefs_font;
+ GtkWidget *w_prefs_sys_font;
+ GtkWidget *w_prefs_sticky;
+ GtkWidget *w_prefs_force;
+ GtkWidget *w_prefs_desktop;
+
+ GList *notes; /* Linked-List of all the sticky notes */
+ GList *applets; /* Linked-List of all the applets */
+
+ cairo_surface_t *icon_normal; /* Normal applet icon */
+ cairo_surface_t *icon_prelight; /* Prelighted applet icon */
+
+ GSettings *settings; /* Shared GSettings */
+
+ gint max_height;
+ guint last_timeout_data;
+
+ gboolean visible; /* Toggle show/hide notes */
} StickyNotes;
/* Sticky Notes Applet */
typedef struct
{
- GtkWidget *w_applet; /* The applet */
- GtkWidget *w_image; /* The applet icon */
+ GtkWidget *w_applet; /* The applet */
+ GtkWidget *w_image; /* The applet icon */
- GtkWidget *destroy_all_dialog; /* The applet it's destroy all dialog */
-
- gboolean prelighted; /* Whether applet is prelighted */
+ GtkWidget *destroy_all_dialog; /* The applet it's destroy all dialog */
- gint panel_size;
- MatePanelAppletOrient panel_orient;
+ gboolean prelighted; /* Whether applet is prelighted */
- GtkActionGroup *action_group;
- GtkWidget *menu_tip;
+ gint panel_size;
+ MatePanelAppletOrient panel_orient;
+
+ GtkActionGroup *action_group;
+ GtkWidget *menu_tip;
} StickyNotesApplet;
-
+
typedef enum
{
- STICKYNOTES_NEW = 0,
- STICKYNOTES_SET_VISIBLE,
- STICKYNOTES_SET_LOCKED
+ STICKYNOTES_NEW = 0,
+ STICKYNOTES_SET_VISIBLE,
+ STICKYNOTES_SET_LOCKED
} StickyNotesDefaultAction;
extern StickyNotes *stickynotes;
-void stickynotes_applet_init(MatePanelApplet *mate_panel_applet);
-void stickynotes_applet_init_prefs(void);
+void stickynotes_applet_init (MatePanelApplet *mate_panel_applet);
+void stickynotes_applet_init_prefs (void);
-StickyNotesApplet * stickynotes_applet_new(MatePanelApplet *mate_panel_applet);
+StickyNotesApplet * stickynotes_applet_new (MatePanelApplet *mate_panel_applet);
-void stickynotes_applet_update_icon(StickyNotesApplet *applet);
-void stickynotes_applet_update_prefs(void);
-void stickynotes_applet_update_menus(void);
-void stickynotes_applet_update_tooltips(void);
+void stickynotes_applet_update_icon (StickyNotesApplet *applet);
+void stickynotes_applet_update_prefs (void);
+void stickynotes_applet_update_menus (void);
+void stickynotes_applet_update_tooltips (void);
-void stickynotes_applet_do_default_action(GdkScreen *screen);
+void stickynotes_applet_do_default_action (GdkScreen *screen);
-void stickynotes_applet_panel_icon_get_geometry (int *x, int *y, int *width, int *height);
+void stickynotes_applet_panel_icon_get_geometry (int *x,
+ int *y,
+ int *width,
+ int *height);
#endif /* __STICKYNOTES_APPLET_H__ */
diff --git a/stickynotes/stickynotes_applet_callbacks.c b/stickynotes/stickynotes_applet_callbacks.c
index 43ad8feb..e643dcb7 100644
--- a/stickynotes/stickynotes_applet_callbacks.c
+++ b/stickynotes/stickynotes_applet_callbacks.c
@@ -27,59 +27,58 @@
static gboolean get_desktop_window (Window *window)
{
- Window *desktop_window;
- GdkWindow *root_window;
- GdkAtom type_returned;
- int format_returned;
- int length_returned;
-
- root_window = gdk_screen_get_root_window (
- gdk_screen_get_default ());
-
- if (gdk_property_get (root_window,
- gdk_atom_intern ("CAJA_DESKTOP_WINDOW_ID", FALSE),
- gdk_x11_xatom_to_atom (XA_WINDOW),
- 0, 4, FALSE,
- &type_returned,
- &format_returned,
- &length_returned,
- (guchar**) &desktop_window)) {
- *window = *desktop_window;
- g_free (desktop_window);
- return TRUE;
- }
- else {
- *window = 0;
- return FALSE;
- }
+ Window *desktop_window;
+ GdkWindow *root_window;
+ GdkAtom type_returned;
+ int format_returned;
+ int length_returned;
+
+ root_window = gdk_screen_get_root_window (gdk_screen_get_default ());
+
+ if (gdk_property_get (root_window,
+ gdk_atom_intern ("CAJA_DESKTOP_WINDOW_ID", FALSE),
+ gdk_x11_xatom_to_atom (XA_WINDOW),
+ 0, 4, FALSE,
+ &type_returned,
+ &format_returned,
+ &length_returned,
+ (guchar**) &desktop_window)) {
+ *window = *desktop_window;
+ g_free (desktop_window);
+ return TRUE;
+ }
+ else {
+ *window = 0;
+ return FALSE;
+ }
}
static void
-popup_add_note (StickyNotesApplet *applet, GtkWidget *item)
+popup_add_note (StickyNotesApplet *applet,
+ GtkWidget *item)
{
- stickynotes_add (gtk_widget_get_screen (applet->w_applet));
+ stickynotes_add (gtk_widget_get_screen (applet->w_applet));
}
static void
stickynote_show_notes (gboolean visible)
{
- StickyNote *note;
- GList *l;
+ StickyNote *note;
+ GList *l;
if (stickynotes->visible == visible) return;
stickynotes->visible = visible;
- for (l = stickynotes->notes; l; l = l->next)
- {
- note = l->data;
- stickynote_set_visible (note, visible);
- }
+ for (l = stickynotes->notes; l; l = l->next) {
+ note = l->data;
+ stickynote_set_visible (note, visible);
+ }
}
static void
stickynote_toggle_notes_visible (void)
{
- stickynote_show_notes(!stickynotes->visible);
+ stickynote_show_notes (!stickynotes->visible);
}
/* Applet Callback : Mouse button press on the applet. */
@@ -88,18 +87,16 @@ applet_button_cb (GtkWidget *widget,
GdkEventButton *event,
StickyNotesApplet *applet)
{
- if (event->type == GDK_2BUTTON_PRESS)
- {
- popup_add_note (applet, NULL);
- return TRUE;
- }
- else if (event->button == 1)
- {
- stickynote_toggle_notes_visible ();
- return TRUE;
- }
-
- return FALSE;
+ if (event->type == GDK_2BUTTON_PRESS) {
+ popup_add_note (applet, NULL);
+ return TRUE;
+ }
+ else if (event->button == 1) {
+ stickynote_toggle_notes_visible ();
+ return TRUE;
+ }
+
+ return FALSE;
}
/* Applet Callback : Keypress on the applet. */
@@ -108,452 +105,537 @@ applet_key_cb (GtkWidget *widget,
GdkEventKey *event,
StickyNotesApplet *applet)
{
- switch (event->keyval)
- {
- case GDK_KEY_KP_Space:
- case GDK_KEY_space:
- case GDK_KEY_KP_Enter:
- case GDK_KEY_Return:
- stickynote_show_notes (TRUE);
- return TRUE;
- }
- return FALSE;
+ switch (event->keyval) {
+ case GDK_KEY_KP_Space:
+ case GDK_KEY_space:
+ case GDK_KEY_KP_Enter:
+ case GDK_KEY_Return:
+ stickynote_show_notes (TRUE);
+ return TRUE;
+ }
+ return FALSE;
}
/* Applet Callback : Cross (enter or leave) the applet. */
-gboolean applet_cross_cb(GtkWidget *widget, GdkEventCrossing *event, StickyNotesApplet *applet)
+gboolean
+applet_cross_cb (GtkWidget *widget,
+ GdkEventCrossing *event,
+ StickyNotesApplet *applet)
{
- applet->prelighted = event->type == GDK_ENTER_NOTIFY || gtk_widget_has_focus(widget);
+ applet->prelighted =
+ event->type == GDK_ENTER_NOTIFY || gtk_widget_has_focus (widget);
- stickynotes_applet_update_icon(applet);
+ stickynotes_applet_update_icon (applet);
- return FALSE;
+ return FALSE;
}
/* Applet Callback : On focus (in or out) of the applet. */
-gboolean applet_focus_cb(GtkWidget *widget, GdkEventFocus *event, StickyNotesApplet *applet)
+gboolean
+applet_focus_cb (GtkWidget *widget,
+ GdkEventFocus *event,
+ StickyNotesApplet *applet)
{
- stickynotes_applet_update_icon(applet);
+ stickynotes_applet_update_icon (applet);
- return FALSE;
+ return FALSE;
}
-static GdkFilterReturn desktop_window_event_filter (GdkXEvent *xevent,
- GdkEvent *event,
- gpointer data)
+static GdkFilterReturn
+desktop_window_event_filter (GdkXEvent *xevent,
+ GdkEvent *event,
+ gpointer data)
{
- gboolean desktop_hide = g_settings_get_boolean (stickynotes->settings, "desktop-hide");
- if (desktop_hide &&
- (((XEvent*)xevent)->xany.type == PropertyNotify) &&
- (((XEvent*)xevent)->xproperty.atom == gdk_x11_get_xatom_by_name ("_NET_WM_USER_TIME"))) {
- stickynote_show_notes (FALSE);
- }
- return GDK_FILTER_CONTINUE;
+ gboolean desktop_hide = g_settings_get_boolean (stickynotes->settings,
+ "desktop-hide");
+ if (desktop_hide &&
+ (((XEvent*)xevent)->xany.type == PropertyNotify) &&
+ (((XEvent*)xevent)->xproperty.atom == gdk_x11_get_xatom_by_name ("_NET_WM_USER_TIME"))) {
+ stickynote_show_notes (FALSE);
+ }
+ return GDK_FILTER_CONTINUE;
}
void install_check_click_on_desktop (void)
{
- Window desktop_window;
- GdkWindow *window;
- Atom user_time_window;
- Atom user_time;
-
- if (!get_desktop_window (&desktop_window)) {
- return;
- }
-
- /* Access the desktop window. desktop_window is the root window for the
- * default screen, so we know using gdk_display_get_default() is correct. */
- window = gdk_x11_window_foreign_new_for_display (gdk_display_get_default (),
- desktop_window);
-
- /* It may contain an atom to tell us which other window to monitor */
- user_time_window = gdk_x11_get_xatom_by_name ("_NET_WM_USER_TIME_WINDOW");
- user_time = gdk_x11_get_xatom_by_name ("_NET_WM_USER_TIME");
- if (user_time != None && user_time_window != None)
- {
- /* Looks like the atoms are there */
- Atom actual_type;
- Window *data;
- int actual_format;
- gulong nitems;
- gulong bytes;
-
- /* We only use this extra property if the actual user-time property's missing */
- XGetWindowProperty(GDK_DISPLAY_XDISPLAY(gdk_window_get_display(window)), desktop_window, user_time,
- 0, 4, False, AnyPropertyType, &actual_type, &actual_format,
- &nitems, &bytes, (unsigned char **)&data );
- if (actual_type == None)
- {
- /* No user-time property, so look for the user-time-window */
- XGetWindowProperty(GDK_DISPLAY_XDISPLAY(gdk_window_get_display(window)), desktop_window, user_time_window,
- 0, 4, False, AnyPropertyType, &actual_type, &actual_format,
- &nitems, &bytes, (unsigned char **)&data );
- if (actual_type != None)
- {
- /* We have another window to monitor */
- desktop_window = *data;
- window = gdk_x11_window_foreign_new_for_display (gdk_window_get_display (window),
- desktop_window);
- }
- }
- }
-
- gdk_window_set_events (window, GDK_PROPERTY_CHANGE_MASK);
- gdk_window_add_filter (window, desktop_window_event_filter, NULL);
+ Window desktop_window;
+ GdkWindow *window;
+ Atom user_time_window;
+ Atom user_time;
+
+ if (!get_desktop_window (&desktop_window)) {
+ return;
+ }
+
+ /* Access the desktop window. desktop_window is the root window for the
+ * default screen, so we know using gdk_display_get_default () is correct. */
+ window = gdk_x11_window_foreign_new_for_display (gdk_display_get_default (),
+ desktop_window);
+
+ /* It may contain an atom to tell us which other window to monitor */
+ user_time_window = gdk_x11_get_xatom_by_name ("_NET_WM_USER_TIME_WINDOW");
+ user_time = gdk_x11_get_xatom_by_name ("_NET_WM_USER_TIME");
+ if (user_time != None && user_time_window != None) {
+ /* Looks like the atoms are there */
+ Atom actual_type;
+ Window *data;
+ int actual_format;
+ gulong nitems;
+ gulong bytes;
+
+ /* We only use this extra property if the actual user-time property's missing */
+ XGetWindowProperty (GDK_DISPLAY_XDISPLAY (gdk_window_get_display (window)),
+ desktop_window, user_time,
+ 0, 4, False, AnyPropertyType,
+ &actual_type, &actual_format,
+ &nitems, &bytes, (unsigned char **)&data);
+ if (actual_type == None) {
+ /* No user-time property, so look for the user-time-window */
+ XGetWindowProperty (GDK_DISPLAY_XDISPLAY (gdk_window_get_display (window)),
+ desktop_window, user_time_window,
+ 0, 4, False, AnyPropertyType,
+ &actual_type, &actual_format,
+ &nitems, &bytes, (unsigned char **)&data);
+ if (actual_type != None) {
+ /* We have another window to monitor */
+ desktop_window = *data;
+ window = gdk_x11_window_foreign_new_for_display (gdk_window_get_display (window),
+ desktop_window);
+ }
+ }
+ }
+
+ gdk_window_set_events (window, GDK_PROPERTY_CHANGE_MASK);
+ gdk_window_add_filter (window, desktop_window_event_filter, NULL);
}
/* Applet Callback : Change the panel orientation. */
-void applet_change_orient_cb(MatePanelApplet *mate_panel_applet, MatePanelAppletOrient orient, StickyNotesApplet *applet)
+void
+applet_change_orient_cb (MatePanelApplet *mate_panel_applet,
+ MatePanelAppletOrient orient,
+ StickyNotesApplet *applet)
{
- applet->panel_orient = orient;
+ applet->panel_orient = orient;
}
/* Applet Callback : Resize the applet. */
-void applet_size_allocate_cb(GtkWidget *widget, GtkAllocation *allocation, StickyNotesApplet *applet)
+void
+applet_size_allocate_cb (GtkWidget *widget,
+ GtkAllocation *allocation,
+ StickyNotesApplet *applet)
{
- if ((applet->panel_orient == MATE_PANEL_APPLET_ORIENT_UP) || (applet->panel_orient == MATE_PANEL_APPLET_ORIENT_DOWN)) {
- if (applet->panel_size == allocation->height)
- return;
- applet->panel_size = allocation->height;
- } else {
- if (applet->panel_size == allocation->width)
- return;
- applet->panel_size = allocation->width;
- }
-
- stickynotes_applet_update_icon(applet);
-
- return;
+ if ((applet->panel_orient == MATE_PANEL_APPLET_ORIENT_UP)
+ || (applet->panel_orient == MATE_PANEL_APPLET_ORIENT_DOWN)) {
+ if (applet->panel_size == allocation->height)
+ return;
+ applet->panel_size = allocation->height;
+ } else {
+ if (applet->panel_size == allocation->width)
+ return;
+ applet->panel_size = allocation->width;
+ }
+
+ stickynotes_applet_update_icon (applet);
+
+ return;
}
/* Applet Callback : Deletes the applet. */
-void applet_destroy_cb (MatePanelApplet *mate_panel_applet, StickyNotesApplet *applet)
+void
+applet_destroy_cb (MatePanelApplet *mate_panel_applet,
+ StickyNotesApplet *applet)
{
- GList *notes;
+ GList *notes;
- stickynotes_save_now ();
+ stickynotes_save_now ();
- if (applet->destroy_all_dialog != NULL)
- gtk_widget_destroy (applet->destroy_all_dialog);
+ if (applet->destroy_all_dialog != NULL)
+ gtk_widget_destroy (applet->destroy_all_dialog);
- if (applet->action_group)
- g_object_unref (applet->action_group);
+ if (applet->action_group)
+ g_object_unref (applet->action_group);
- if (stickynotes->applets != NULL)
- stickynotes->applets = g_list_remove (stickynotes->applets, applet);
+ if (stickynotes->applets != NULL)
+ stickynotes->applets = g_list_remove (stickynotes->applets,
+ applet);
- if (stickynotes->applets == NULL) {
- notes = stickynotes->notes;
- while (notes) {
- StickyNote *note = notes->data;
- stickynote_free (note);
- notes = g_list_next (notes);
- }
- }
+ if (stickynotes->applets == NULL) {
+ notes = stickynotes->notes;
+ while (notes) {
+ StickyNote *note = notes->data;
+ stickynote_free (note);
+ notes = g_list_next (notes);
+ }
+ }
}
/* Destroy all response Callback: Callback for the destroy all dialog */
static void
-destroy_all_response_cb (GtkDialog *dialog, gint id, StickyNotesApplet *applet)
+destroy_all_response_cb (GtkDialog *dialog,
+ gint id,
+ StickyNotesApplet *applet)
{
- if (id == GTK_RESPONSE_OK) {
- while (g_list_length(stickynotes->notes) > 0) {
- StickyNote *note = g_list_nth_data(stickynotes->notes, 0);
- stickynote_free(note);
- stickynotes->notes = g_list_remove(stickynotes->notes, note);
- }
- }
-
- stickynotes_applet_update_tooltips();
- stickynotes_save();
-
- gtk_widget_destroy (GTK_WIDGET (dialog));
- applet->destroy_all_dialog = NULL;
+ if (id == GTK_RESPONSE_OK) {
+ while (g_list_length (stickynotes->notes) > 0) {
+ StickyNote *note = g_list_nth_data (stickynotes->notes, 0);
+ stickynote_free (note);
+ stickynotes->notes = g_list_remove (stickynotes->notes, note);
+ }
+ }
+
+ stickynotes_applet_update_tooltips ();
+ stickynotes_save ();
+
+ gtk_widget_destroy (GTK_WIDGET (dialog));
+ applet->destroy_all_dialog = NULL;
}
/* Menu Callback : New Note */
-void menu_new_note_cb(GtkAction *action, StickyNotesApplet *applet)
+void
+menu_new_note_cb (GtkAction *action,
+ StickyNotesApplet *applet)
{
- popup_add_note (applet, NULL);
+ popup_add_note (applet, NULL);
}
/* Menu Callback : Hide Notes */
-void menu_hide_notes_cb(GtkAction *action, StickyNotesApplet *applet)
+void
+menu_hide_notes_cb (GtkAction *action,
+ StickyNotesApplet *applet)
{
- stickynote_show_notes (FALSE);
+ stickynote_show_notes (FALSE);
}
/* Menu Callback : Destroy all sticky notes */
-void menu_destroy_all_cb(GtkAction *action, StickyNotesApplet *applet)
+void
+menu_destroy_all_cb (GtkAction *action,
+ StickyNotesApplet *applet)
{
- GtkBuilder *builder;
+ GtkBuilder *builder;
- builder = gtk_builder_new ();
- gtk_builder_add_from_resource (builder, GRESOURCE "sticky-notes-delete-all.ui", NULL);
+ builder = gtk_builder_new ();
+ gtk_builder_add_from_resource (builder,
+ GRESOURCE "sticky-notes-delete-all.ui",
+ NULL);
- if (applet->destroy_all_dialog != NULL) {
- gtk_window_set_screen (GTK_WINDOW (applet->destroy_all_dialog),
- gtk_widget_get_screen (GTK_WIDGET (applet->w_applet)));
+ if (applet->destroy_all_dialog != NULL) {
+ gtk_window_set_screen (GTK_WINDOW (applet->destroy_all_dialog),
+ gtk_widget_get_screen (GTK_WIDGET (applet->w_applet)));
- gtk_window_present (GTK_WINDOW (applet->destroy_all_dialog));
- return;
- }
+ gtk_window_present (GTK_WINDOW (applet->destroy_all_dialog));
+ return;
+ }
- applet->destroy_all_dialog = GTK_WIDGET (gtk_builder_get_object (builder, "delete_all_dialog"));
+ applet->destroy_all_dialog = GTK_WIDGET (gtk_builder_get_object (builder,
+ "delete_all_dialog"));
- g_object_unref (builder);
+ g_object_unref (builder);
- g_signal_connect (applet->destroy_all_dialog, "response",
- G_CALLBACK (destroy_all_response_cb),
- applet);
+ g_signal_connect (applet->destroy_all_dialog, "response",
+ G_CALLBACK (destroy_all_response_cb),
+ applet);
- gtk_window_set_screen (GTK_WINDOW (applet->destroy_all_dialog),
- gtk_widget_get_screen (applet->w_applet));
+ gtk_window_set_screen (GTK_WINDOW (applet->destroy_all_dialog),
+ gtk_widget_get_screen (applet->w_applet));
- gtk_widget_show_all (applet->destroy_all_dialog);
+ gtk_widget_show_all (applet->destroy_all_dialog);
}
/* Menu Callback: Lock/Unlock sticky notes */
-void menu_toggle_lock_cb(GtkAction *action, StickyNotesApplet *applet)
+void
+menu_toggle_lock_cb (GtkAction *action,
+ StickyNotesApplet *applet)
{
- gboolean locked = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+ gboolean locked = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
- if (g_settings_is_writable (stickynotes->settings, "locked"))
- g_settings_set_boolean (stickynotes->settings, "locked", locked);
+ if (g_settings_is_writable (stickynotes->settings, "locked"))
+ g_settings_set_boolean (stickynotes->settings, "locked", locked);
}
/* Menu Callback : Configure preferences */
-void menu_preferences_cb(GtkAction *action, StickyNotesApplet *applet)
+void
+menu_preferences_cb (GtkAction *action,
+ StickyNotesApplet *applet)
{
- stickynotes_applet_update_prefs();
- gtk_window_set_screen(GTK_WINDOW(stickynotes->w_prefs), gtk_widget_get_screen(applet->w_applet));
- gtk_window_present(GTK_WINDOW(stickynotes->w_prefs));
+ stickynotes_applet_update_prefs ();
+ gtk_window_set_screen (GTK_WINDOW (stickynotes->w_prefs),
+ gtk_widget_get_screen (applet->w_applet));
+ gtk_window_present (GTK_WINDOW (stickynotes->w_prefs));
}
/* Menu Callback : Show help */
-void menu_help_cb(GtkAction *action, StickyNotesApplet *applet)
+void
+menu_help_cb (GtkAction *action,
+ StickyNotesApplet *applet)
{
- GError *error = NULL;
-
- gtk_show_uri_on_window (NULL,
- "help:mate-stickynotes-applet",
- gtk_get_current_event_time (),
- &error);
- if (error) {
- GtkWidget *dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE,
- _("There was an error displaying help: %s"), error->message);
- g_signal_connect(G_OBJECT(dialog), "response", G_CALLBACK(gtk_widget_destroy), NULL);
- gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE);
- gtk_window_set_screen (GTK_WINDOW(dialog), gtk_widget_get_screen(applet->w_applet));
- gtk_widget_show(dialog);
- g_error_free(error);
- }
+ GError *error = NULL;
+
+ gtk_show_uri_on_window (NULL,
+ "help:mate-stickynotes-applet",
+ gtk_get_current_event_time (),
+ &error);
+
+ if (error) {
+ GtkWidget *dialog = gtk_message_dialog_new (NULL,
+ GTK_DIALOG_MODAL,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_CLOSE,
+ _("There was an error displaying help: %s"),
+ error->message);
+
+ g_signal_connect (dialog,
+ "response",
+ G_CALLBACK (gtk_widget_destroy),
+ NULL);
+
+ gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
+ gtk_window_set_screen (GTK_WINDOW (dialog),
+ gtk_widget_get_screen (applet->w_applet));
+ gtk_widget_show (dialog);
+ g_error_free (error);
+ }
}
/* Menu Callback : Display About window */
void
-menu_about_cb (GtkAction *action,
- StickyNotesApplet *applet)
+menu_about_cb (GtkAction *action,
+ StickyNotesApplet *applet)
{
- static const gchar *authors[] = {
- "Loban A Rahman <[email protected]>",
- "Davyd Madeley <[email protected]>",
- NULL
- };
-
- static const gchar *documenters[] = {
- "Loban A Rahman <[email protected]>",
- N_("Sun GNOME Documentation Team <[email protected]>"),
- N_("MATE Documentation Team"),
- NULL
- };
+ static const gchar *authors[] = {
+ "Loban A Rahman <[email protected]>",
+ "Davyd Madeley <[email protected]>",
+ NULL
+ };
+
+ static const gchar *documenters[] = {
+ "Loban A Rahman <[email protected]>",
+ N_("Sun GNOME Documentation Team <[email protected]>"),
+ N_("MATE Documentation Team"),
+ NULL
+ };
#ifdef ENABLE_NLS
- const char **p;
- for (p = documenters; *p; ++p)
- *p = _(*p);
+ const char **p;
+ for (p = documenters; *p; ++p)
+ *p = _(*p);
#endif
- gtk_show_about_dialog (NULL,
- "title", _("About Sticky Notes"),
- "version", VERSION,
- "copyright", _("Copyright \xc2\xa9 2002-2003 Loban A Rahman\n"
- "Copyright \xc2\xa9 2005 Davyd Madeley\n"
- "Copyright \xc2\xa9 2012-2020 MATE developers"),
- "comments", _("Sticky Notes for the "
- "MATE Desktop Environment"),
- "authors", authors,
- "documenters", documenters,
- "translator-credits", _("translator-credits"),
- "logo-icon-name", "mate-sticky-notes-applet",
- NULL);
+ gtk_show_about_dialog (NULL,
+ "title", _("About Sticky Notes"),
+ "version", VERSION,
+ "copyright", _("Copyright \xc2\xa9 2002-2003 Loban A Rahman\n"
+ "Copyright \xc2\xa9 2005 Davyd Madeley\n"
+ "Copyright \xc2\xa9 2012-2020 MATE developers"),
+ "comments", _("Sticky Notes for the "
+ "MATE Desktop Environment"),
+ "authors", authors,
+ "documenters", documenters,
+ "translator-credits", _("translator-credits"),
+ "logo-icon-name", "mate-sticky-notes-applet",
+ NULL);
}
/* Preferences Callback : Save. */
void
preferences_save_cb (gpointer data)
{
- gint width = gtk_adjustment_get_value (stickynotes->w_prefs_width);
- gint height = gtk_adjustment_get_value (stickynotes->w_prefs_height);
- gboolean sys_color = gtk_toggle_button_get_active (
- GTK_TOGGLE_BUTTON (stickynotes->w_prefs_sys_color));
- gboolean sys_font = gtk_toggle_button_get_active (
- GTK_TOGGLE_BUTTON (stickynotes->w_prefs_sys_font));
- gboolean sticky = gtk_toggle_button_get_active (
- GTK_TOGGLE_BUTTON (stickynotes->w_prefs_sticky));
- gboolean force_default = gtk_toggle_button_get_active (
- GTK_TOGGLE_BUTTON (stickynotes->w_prefs_force));
- gboolean desktop_hide = gtk_toggle_button_get_active (
- GTK_TOGGLE_BUTTON (stickynotes->w_prefs_desktop));
-
- if (g_settings_is_writable (stickynotes->settings,"default-width"))
- g_settings_set_int (stickynotes->settings,"default-width", width);
- if (g_settings_is_writable (stickynotes->settings,"default-height"))
- g_settings_set_int (stickynotes->settings,"default-height", height);
- if (g_settings_is_writable (stickynotes->settings,"use-system-color"))
- g_settings_set_boolean (stickynotes->settings,"use-system-color", sys_color);
- if (g_settings_is_writable (stickynotes->settings,"use-system-font"))
- g_settings_set_boolean (stickynotes->settings,"use-system-font", sys_font);
- if (g_settings_is_writable (stickynotes->settings,"sticky"))
- g_settings_set_boolean (stickynotes->settings,"sticky", sticky);
- if (g_settings_is_writable (stickynotes->settings,"force-default"))
- g_settings_set_boolean (stickynotes->settings,"force-default", force_default);
- if (g_settings_is_writable (stickynotes->settings,"desktop-hide"))
- g_settings_set_boolean (stickynotes->settings,"desktop-hide", desktop_hide);
+ gint width = gtk_adjustment_get_value (stickynotes->w_prefs_width);
+ gint height = gtk_adjustment_get_value (stickynotes->w_prefs_height);
+ gboolean sys_color =
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (stickynotes->w_prefs_sys_color));
+ gboolean sys_font =
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (stickynotes->w_prefs_sys_font));
+ gboolean sticky =
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (stickynotes->w_prefs_sticky));
+ gboolean force_default =
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (stickynotes->w_prefs_force));
+ gboolean desktop_hide =
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (stickynotes->w_prefs_desktop));
+
+ if (g_settings_is_writable (stickynotes->settings,
+ "default-width"))
+ g_settings_set_int (stickynotes->settings,
+ "default-width", width);
+ if (g_settings_is_writable (stickynotes->settings,
+ "default-height"))
+ g_settings_set_int (stickynotes->settings,
+ "default-height", height);
+ if (g_settings_is_writable (stickynotes->settings,
+ "use-system-color"))
+ g_settings_set_boolean (stickynotes->settings,
+ "use-system-color", sys_color);
+ if (g_settings_is_writable (stickynotes->settings,
+ "use-system-font"))
+ g_settings_set_boolean (stickynotes->settings,
+ "use-system-font", sys_font);
+ if (g_settings_is_writable (stickynotes->settings,
+ "sticky"))
+ g_settings_set_boolean (stickynotes->settings,
+ "sticky", sticky);
+ if (g_settings_is_writable (stickynotes->settings,
+ "force-default"))
+ g_settings_set_boolean (stickynotes->settings,
+ "force-default", force_default);
+ if (g_settings_is_writable (stickynotes->settings,
+ "desktop-hide"))
+ g_settings_set_boolean (stickynotes->settings,
+ "desktop-hide", desktop_hide);
}
/* Preferences Callback : Change color. */
void
-preferences_color_cb (GtkWidget *button, gpointer data)
+preferences_color_cb (GtkWidget *button,
+ gpointer data)
{
- char *color_str, *font_color_str;
+ char *color_str, *font_color_str;
- GdkRGBA color, font_color;
+ GdkRGBA color, font_color;
- gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (stickynotes->w_prefs_color), &color);
- gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (stickynotes->w_prefs_font_color), &font_color);
+ gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (stickynotes->w_prefs_color),
+ &color);
+ gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (stickynotes->w_prefs_font_color),
+ &font_color);
- color_str = gdk_rgba_to_string (&color);
- font_color_str = gdk_rgba_to_string (&font_color);
+ color_str = gdk_rgba_to_string (&color);
+ font_color_str = gdk_rgba_to_string (&font_color);
- g_settings_set_string (stickynotes->settings, "default-color", color_str);
- g_settings_set_string (stickynotes->settings, "default-font-color", font_color_str);
+ g_settings_set_string (stickynotes->settings,
+ "default-color",
+ color_str);
+ g_settings_set_string (stickynotes->settings,
+ "default-font-color",
+ font_color_str);
- g_free (color_str);
- g_free (font_color_str);
+ g_free (color_str);
+ g_free (font_color_str);
}
/* Preferences Callback : Change font. */
-void preferences_font_cb (GtkWidget *button, gpointer data)
+void
+preferences_font_cb (GtkWidget *button,
+ gpointer data)
{
- const char *font_str;
+ const char *font_str;
- font_str = gtk_font_button_get_font_name (GTK_FONT_BUTTON (button));
- g_settings_set_string (stickynotes->settings, "default-font", font_str);
+ font_str = gtk_font_button_get_font_name (GTK_FONT_BUTTON (button));
+ g_settings_set_string (stickynotes->settings,
+ "default-font",
+ font_str);
}
/* Preferences Callback : Apply to existing notes. */
-void preferences_apply_cb(GSettings *settings, gchar *key, gpointer data)
+void
+preferences_apply_cb (GSettings *settings,
+ gchar *key,
+ gpointer data)
{
- GList *l;
- StickyNote *note;
-
- if (!strcmp (key, "sticky"))
- {
- if (g_settings_get_boolean (settings, key))
- for (l = stickynotes->notes; l; l = l->next)
- {
- note = l->data;
- gtk_window_stick (GTK_WINDOW (note->w_window));
- }
- else
- for (l = stickynotes->notes; l; l = l->next)
- {
- note = l->data;
- gtk_window_unstick (GTK_WINDOW (
- note->w_window));
- }
- }
-
- else if (!strcmp (key, "locked"))
- {
- for (l = stickynotes->notes; l; l = l->next)
- {
- note = l->data;
- stickynote_set_locked (note,
- g_settings_get_boolean (settings, key));
- }
- stickynotes_save();
- }
-
- else if (!strcmp (key, "use-system-color") ||
- !strcmp (key, "default-color"))
- {
- for (l = stickynotes->notes; l; l = l->next)
- {
- note = l->data;
- stickynote_set_color (note,
- note->color, note->font_color,
- FALSE);
- }
- }
-
- else if (!strcmp (key, "use-system-font") ||
- !strcmp (key, "default-font"))
- {
- for (l = stickynotes->notes; l; l = l->next)
- {
- note = l->data;
- stickynote_set_font (note, note->font, FALSE);
- }
- }
-
- else if (!strcmp (key, "force-default"))
- {
- for (l = stickynotes->notes; l; l = l->next)
- {
- note = l->data;
- stickynote_set_color(note,
- note->color, note->font_color,
- FALSE);
- stickynote_set_font(note, note->font, FALSE);
- }
- }
-
- stickynotes_applet_update_prefs();
- stickynotes_applet_update_menus();
+ GList *l;
+ StickyNote *note;
+
+ if (!strcmp (key, "sticky")) {
+ if (g_settings_get_boolean (settings, key))
+ for (l = stickynotes->notes; l; l = l->next) {
+ note = l->data;
+ gtk_window_stick (GTK_WINDOW (note->w_window));
+ }
+ else
+ for (l = stickynotes->notes; l; l = l->next) {
+ note = l->data;
+ gtk_window_unstick (GTK_WINDOW (note->w_window));
+ }
+ }
+
+ else if (!strcmp (key, "locked")) {
+ for (l = stickynotes->notes; l; l = l->next) {
+ note = l->data;
+ stickynote_set_locked (note,
+ g_settings_get_boolean (settings, key));
+ }
+ stickynotes_save ();
+ }
+
+ else if (!strcmp (key, "use-system-color") ||
+ !strcmp (key, "default-color")) {
+ for (l = stickynotes->notes; l; l = l->next) {
+ note = l->data;
+ stickynote_set_color (note,
+ note->color,
+ note->font_color,
+ FALSE);
+ }
+ }
+
+ else if (!strcmp (key, "use-system-font") ||
+ !strcmp (key, "default-font")) {
+ for (l = stickynotes->notes; l; l = l->next) {
+ note = l->data;
+ stickynote_set_font (note, note->font, FALSE);
+ }
+ }
+
+ else if (!strcmp (key, "force-default")) {
+ for (l = stickynotes->notes; l; l = l->next) {
+ note = l->data;
+ stickynote_set_color (note,
+ note->color,
+ note->font_color,
+ FALSE);
+ stickynote_set_font (note,
+ note->font,
+ FALSE);
+ }
+ }
+
+ stickynotes_applet_update_prefs ();
+ stickynotes_applet_update_menus ();
}
/* Preferences Callback : Response. */
-void preferences_response_cb(GtkWidget *dialog, gint response, gpointer data)
+void
+preferences_response_cb (GtkWidget *dialog,
+ gint response,
+ gpointer data)
{
- if (response == GTK_RESPONSE_HELP) {
- GError *error = NULL;
-
- gtk_show_uri_on_window (GTK_WINDOW (dialog),
- "help:mate-stickynotes-applet/stickynotes-advanced-settings",
- gtk_get_current_event_time (),
- &error);
- if (error) {
- dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE,
- _("There was an error displaying help: %s"), error->message);
- g_signal_connect(G_OBJECT(dialog), "response", G_CALLBACK(gtk_widget_destroy), NULL);
- gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE);
- gtk_window_set_screen (GTK_WINDOW(dialog), gtk_widget_get_screen(GTK_WIDGET(dialog)));
- gtk_widget_show(dialog);
- g_error_free(error);
- }
- }
-
- else if (response == GTK_RESPONSE_CLOSE)
- gtk_widget_hide(GTK_WIDGET(dialog));
+ if (response == GTK_RESPONSE_HELP) {
+ GError *error = NULL;
+
+ gtk_show_uri_on_window (GTK_WINDOW (dialog),
+ "help:mate-stickynotes-applet/stickynotes-advanced-settings",
+ gtk_get_current_event_time (),
+ &error);
+
+ if (error) {
+ dialog = gtk_message_dialog_new (NULL,
+ GTK_DIALOG_MODAL,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_CLOSE,
+ _("There was an error displaying help: %s"),
+ error->message);
+
+ g_signal_connect (G_OBJECT (dialog),
+ "response",
+ G_CALLBACK (gtk_widget_destroy),
+ NULL);
+ gtk_window_set_resizable (GTK_WINDOW (dialog),
+ FALSE);
+ gtk_window_set_screen (GTK_WINDOW (dialog),
+ gtk_widget_get_screen (GTK_WIDGET (dialog)));
+ gtk_widget_show (dialog);
+ g_error_free (error);
+ }
+ }
+
+ else if (response == GTK_RESPONSE_CLOSE)
+ gtk_widget_hide (GTK_WIDGET (dialog));
}
/* Preferences Callback : Delete */
-gboolean preferences_delete_cb(GtkWidget *widget, GdkEvent *event, gpointer data)
+gboolean
+preferences_delete_cb (GtkWidget *widget,
+ GdkEvent *event,
+ gpointer data)
{
- gtk_widget_hide(widget);
+ gtk_widget_hide (widget);
- return TRUE;
+ return TRUE;
}
diff --git a/stickynotes/stickynotes_applet_callbacks.h b/stickynotes/stickynotes_applet_callbacks.h
index 3e8603de..1ae2768e 100644
--- a/stickynotes/stickynotes_applet_callbacks.h
+++ b/stickynotes/stickynotes_applet_callbacks.h
@@ -23,30 +23,83 @@
#include <stickynotes_applet.h>
/* Callbacks for the sticky notes applet */
-gboolean applet_button_cb(GtkWidget *widget, GdkEventButton *event, StickyNotesApplet *applet);
-gboolean applet_key_cb(GtkWidget *widget, GdkEventKey *event, StickyNotesApplet *applet);
-gboolean applet_cross_cb(GtkWidget *widget, GdkEventCrossing *event, StickyNotesApplet *applet);
-gboolean applet_focus_cb(GtkWidget *widget, GdkEventFocus *event, StickyNotesApplet *applet);
-void install_check_click_on_desktop (void);
-void applet_change_orient_cb(MatePanelApplet *mate_panel_applet, MatePanelAppletOrient orient, StickyNotesApplet *applet);
-void applet_size_allocate_cb(GtkWidget *widget, GtkAllocation *allocation, StickyNotesApplet *applet);
-void applet_destroy_cb (MatePanelApplet *mate_panel_applet, StickyNotesApplet *applet);
+gboolean
+applet_button_cb (GtkWidget *widget,
+ GdkEventButton *event,
+ StickyNotesApplet *applet);
+gboolean
+applet_key_cb (GtkWidget *widget,
+ GdkEventKey *event,
+ StickyNotesApplet *applet);
+gboolean
+applet_cross_cb (GtkWidget *widget,
+ GdkEventCrossing *event,
+ StickyNotesApplet *applet);
+gboolean
+applet_focus_cb (GtkWidget *widget,
+ GdkEventFocus *event,
+ StickyNotesApplet *applet);
+
+void
+install_check_click_on_desktop (void);
+void
+applet_change_orient_cb (MatePanelApplet *mate_panel_applet,
+ MatePanelAppletOrient orient,
+ StickyNotesApplet *applet);
+void
+applet_size_allocate_cb (GtkWidget *widget,
+ GtkAllocation *allocation,
+ StickyNotesApplet *applet);
+void
+applet_destroy_cb (MatePanelApplet *mate_panel_applet,
+ StickyNotesApplet *applet);
+
/* Callbacks for sticky notes applet menu */
-void menu_create_cb(GtkAction *action, StickyNotesApplet *applet);
-void menu_new_note_cb(GtkAction *action, StickyNotesApplet *applet);
-void menu_hide_notes_cb(GtkAction *action, StickyNotesApplet *applet);
-void menu_destroy_all_cb(GtkAction *action, StickyNotesApplet *applet);
-void menu_toggle_lock_cb(GtkAction *action, StickyNotesApplet *applet);
-void menu_preferences_cb(GtkAction *action, StickyNotesApplet *applet);
-void menu_help_cb(GtkAction *action, StickyNotesApplet *applet);
-void menu_about_cb(GtkAction *action, StickyNotesApplet *applet);
+void
+menu_create_cb (GtkAction *action,
+ StickyNotesApplet *applet);
+void
+menu_new_note_cb (GtkAction *action,
+ StickyNotesApplet *applet);
+void
+menu_hide_notes_cb (GtkAction *action,
+ StickyNotesApplet *applet);
+void
+menu_destroy_all_cb (GtkAction *action,
+ StickyNotesApplet *applet);
+void
+menu_toggle_lock_cb (GtkAction *action,
+ StickyNotesApplet *applet);
+void
+menu_preferences_cb (GtkAction *action,
+ StickyNotesApplet *applet);
+void
+menu_help_cb (GtkAction *action,
+ StickyNotesApplet *applet);
+void
+menu_about_cb (GtkAction *action,
+ StickyNotesApplet *applet);
/* Callbacks for sticky notes preferences dialog */
-void preferences_save_cb(gpointer data);
-void preferences_color_cb (GtkWidget *button, gpointer data);
-void preferences_font_cb (GtkWidget *button, gpointer data);
-void preferences_apply_cb(GSettings *settings, gchar *key, gpointer data);
-void preferences_response_cb(GtkWidget *dialog, gint response, gpointer data);
-gboolean preferences_delete_cb(GtkWidget *widget, GdkEvent *event, gpointer data);
+void
+preferences_save_cb (gpointer data);
+void
+preferences_color_cb (GtkWidget *button,
+ gpointer data);
+void
+preferences_font_cb (GtkWidget *button,
+ gpointer data);
+void
+preferences_apply_cb (GSettings *settings,
+ gchar *key,
+ gpointer data);
+void
+preferences_response_cb (GtkWidget *dialog,
+ gint response,
+ gpointer data);
+gboolean
+preferences_delete_cb (GtkWidget *widget,
+ GdkEvent *event,
+ gpointer data);
-#endif /* __STICKYNOTES_APPLET_CALLBACKS_H__ */ \ No newline at end of file
+#endif /* __STICKYNOTES_APPLET_CALLBACKS_H__ */
diff --git a/stickynotes/stickynotes_callbacks.c b/stickynotes/stickynotes_callbacks.c
index 45a01ad5..1d416f0f 100644
--- a/stickynotes/stickynotes_callbacks.c
+++ b/stickynotes/stickynotes_callbacks.c
@@ -22,170 +22,206 @@
/* Sticky Window Callback : Lock/Unlock the window */
gboolean
-stickynote_toggle_lock_cb (GtkWidget *widget, StickyNote *note)
+stickynote_toggle_lock_cb (GtkWidget *widget,
+ StickyNote *note)
{
- stickynote_set_locked (note, !note->locked);
+ stickynote_set_locked (note, !note->locked);
- return TRUE;
+ return TRUE;
}
/* Sticky Window Callback : Close the window. */
gboolean
-stickynote_close_cb (GtkWidget *widget, StickyNote *note)
+stickynote_close_cb (GtkWidget *widget,
+ StickyNote *note)
{
- stickynotes_remove (note);
-
- return TRUE;
+ stickynotes_remove (note);
+
+ return TRUE;
}
/* Sticky Window Callback : Resize the window. */
-gboolean stickynote_resize_cb(GtkWidget *widget, GdkEventButton *event, StickyNote *note)
-{
- 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), GDK_WINDOW_EDGE_SOUTH_EAST,
- event->button, event->x_root, event->y_root, event->time);
- else /* if (widget == note->w_resize_sw) */
- gtk_window_begin_resize_drag(GTK_WINDOW(note->w_window), GDK_WINDOW_EDGE_SOUTH_WEST,
- event->button, event->x_root, event->y_root, event->time);
- }
- else
- return FALSE;
-
- return TRUE;
+gboolean stickynote_resize_cb (GtkWidget *widget,
+ GdkEventButton *event,
+ StickyNote *note)
+{
+ 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),
+ GDK_WINDOW_EDGE_SOUTH_EAST,
+ event->button, event->x_root,
+ event->y_root, event->time);
+ else /* if (widget == note->w_resize_sw) */
+ gtk_window_begin_resize_drag (GTK_WINDOW (note->w_window),
+ GDK_WINDOW_EDGE_SOUTH_WEST,
+ event->button, event->x_root,
+ event->y_root, event->time);
+ }
+ else
+ return FALSE;
+
+ return TRUE;
}
/* Sticky Window Callback : Move the window or edit the title. */
-gboolean stickynote_move_cb(GtkWidget *widget, GdkEventButton *event, StickyNote *note)
+gboolean
+stickynote_move_cb (GtkWidget *widget,
+ GdkEventButton *event,
+ StickyNote *note)
{
- if (event->type == GDK_BUTTON_PRESS && event->button == 1)
- gtk_window_begin_move_drag(GTK_WINDOW(note->w_window), event->button, event->x_root, event->y_root, event->time);
- else if (event->type == GDK_2BUTTON_PRESS && event->button == 1)
- stickynote_change_properties(note);
- else
- return FALSE;
+ if (event->type == GDK_BUTTON_PRESS && event->button == 1)
+ gtk_window_begin_move_drag (GTK_WINDOW (note->w_window),
+ event->button, event->x_root,
+ event->y_root, event->time);
+ else if (event->type == GDK_2BUTTON_PRESS && event->button == 1)
+ stickynote_change_properties (note);
+ else
+ return FALSE;
- return TRUE;
+ return TRUE;
}
/* Sticky Window Callback : Store settings when resizing/moving the window */
-gboolean stickynote_configure_cb(GtkWidget *widget, GdkEventConfigure *event, StickyNote *note)
+gboolean
+stickynote_configure_cb (GtkWidget *widget,
+ GdkEventConfigure *event,
+ StickyNote *note)
{
- note->x = event->x;
- note->y = event->y;
- note->w = event->width;
- note->h = event->height;
+ note->x = event->x;
+ note->y = event->y;
+ note->w = event->width;
+ note->h = event->height;
- stickynotes_save();
+ stickynotes_save ();
- return FALSE;
+ return FALSE;
}
/* Sticky Window Callback : Get confirmation when deleting the window. */
-gboolean stickynote_delete_cb(GtkWidget *widget, GdkEvent *event, StickyNote *note)
+gboolean
+stickynote_delete_cb (GtkWidget *widget,
+ GdkEvent *event,
+ StickyNote *note)
{
- stickynotes_remove(note);
+ stickynotes_remove (note);
- return TRUE;
+ return TRUE;
}
/* Sticky Window Callback : Popup the right click menu. */
gboolean
-stickynote_show_popup_menu (GtkWidget *widget, GdkEventButton *event, GtkWidget *popup_menu)
+stickynote_show_popup_menu (GtkWidget *widget,
+ GdkEventButton *event,
+ GtkWidget *popup_menu)
{
- if (event->type == GDK_BUTTON_PRESS && event->button == 3)
- {
- gtk_menu_popup_at_pointer (GTK_MENU (popup_menu),
- (const GdkEvent*) event);
- }
+ if (event->type == GDK_BUTTON_PRESS && event->button == 3) {
+ gtk_menu_popup_at_pointer (GTK_MENU (popup_menu),
+ (const GdkEvent*) event);
+ }
- return FALSE;
+ return FALSE;
}
/* Popup Menu Callback : Create a new sticky note */
-void popup_create_cb(GtkWidget *widget, StickyNote *note)
+void popup_create_cb (GtkWidget *widget,
+ StickyNote *note)
{
- stickynotes_add(gtk_widget_get_screen(note->w_window));
+ stickynotes_add (gtk_widget_get_screen (note->w_window));
}
/* Popup Menu Callback : Destroy selected sticky note */
-void popup_destroy_cb(GtkWidget *widget, StickyNote *note)
+void
+popup_destroy_cb (GtkWidget *widget,
+ StickyNote *note)
{
- stickynotes_remove(note);
+ stickynotes_remove (note);
}
/* Popup Menu Callback : Lock/Unlock selected sticky note */
-void popup_toggle_lock_cb(GtkToggleAction *action, StickyNote *note)
+void
+popup_toggle_lock_cb (GtkToggleAction *action,
+ StickyNote *note)
{
- stickynote_set_locked(note, gtk_toggle_action_get_active(action));
+ stickynote_set_locked (note,
+ gtk_toggle_action_get_active (action));
}
/* Popup Menu Callback : Change sticky note properties */
-void popup_properties_cb(GtkWidget *widget, StickyNote *note)
+void
+popup_properties_cb (GtkWidget *widget,
+ StickyNote *note)
{
- stickynote_change_properties(note);
+ stickynote_change_properties (note);
}
/* Properties Dialog Callback : Apply title */
-void properties_apply_title_cb(StickyNote *note)
+void
+properties_apply_title_cb (StickyNote *note)
{
- stickynote_set_title(note, gtk_entry_get_text(GTK_ENTRY(note->w_entry)));
+ stickynote_set_title (note,
+ gtk_entry_get_text (GTK_ENTRY (note->w_entry)));
}
/* Properties Dialog Callback : Apply color */
-void properties_apply_color_cb(StickyNote *note)
+void
+properties_apply_color_cb (StickyNote *note)
{
- char *color_str = NULL;
- char *font_color_str = NULL;
-
- if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(note->w_def_color)))
- {
- GdkRGBA color, font_color;
+ char *color_str = NULL;
+ char *font_color_str = NULL;
+
+ if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (note->w_def_color))) {
+ GdkRGBA color, font_color;
+
+ gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (note->w_color),
+ &color);
+ gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (note->w_font_color),
+ &font_color);
- gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (note->w_color), &color);
- gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (note->w_font_color), &font_color);
+ color_str = gdk_rgba_to_string (&color);
+ font_color_str = gdk_rgba_to_string (&font_color);
+ }
- color_str = gdk_rgba_to_string (&color);
- font_color_str = gdk_rgba_to_string (&font_color);
- }
-
- stickynote_set_color (note, color_str, font_color_str, TRUE);
+ stickynote_set_color (note, color_str,
+ font_color_str, TRUE);
- g_free (color_str);
- g_free (font_color_str);
+ g_free (color_str);
+ g_free (font_color_str);
}
/* Properties Dialog Callback : Apply font */
-void properties_apply_font_cb(StickyNote *note)
+void properties_apply_font_cb (StickyNote *note)
{
- const gchar *font_str = NULL;
-
- if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(note->w_def_font)))
- {
- font_str = gtk_font_button_get_font_name (
- GTK_FONT_BUTTON (note->w_font));
- }
+ const gchar *font_str = NULL;
- stickynote_set_font(note, font_str, TRUE);
+ if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (note->w_def_font)))
+ font_str = gtk_font_button_get_font_name (GTK_FONT_BUTTON (note->w_font));
+
+ stickynote_set_font (note, font_str, TRUE);
}
/* Properties Dialog Callback : Color */
void
-properties_color_cb (GtkWidget *button, StickyNote *note)
+properties_color_cb (GtkWidget *button,
+ StickyNote *note)
{
- properties_apply_color_cb (note);
+ properties_apply_color_cb (note);
}
/* Properties Dialog Callback : Font */
-void properties_font_cb (GtkWidget *button, StickyNote *note)
+void
+properties_font_cb (GtkWidget *button,
+ StickyNote *note)
{
- const char *font_str = gtk_font_button_get_font_name (GTK_FONT_BUTTON (button));
- stickynote_set_font(note, font_str, TRUE);
+ const char *font_str = gtk_font_button_get_font_name (GTK_FONT_BUTTON (button));
+ stickynote_set_font (note, font_str, TRUE);
}
/* Properties Dialog Callback : Activate */
-void properties_activate_cb(GtkWidget *widget, StickyNote *note)
+void
+properties_activate_cb (GtkWidget *widget,
+ StickyNote *note)
{
- gtk_dialog_response(GTK_DIALOG(note->w_properties), GTK_RESPONSE_CLOSE);
+ gtk_dialog_response (GTK_DIALOG (note->w_properties),
+ GTK_RESPONSE_CLOSE);
}
diff --git a/stickynotes/stickynotes_callbacks.h b/stickynotes/stickynotes_callbacks.h
index 5918be99..42c86bb1 100644
--- a/stickynotes/stickynotes_callbacks.h
+++ b/stickynotes/stickynotes_callbacks.h
@@ -23,26 +23,62 @@
#include <stickynotes.h>
/* Callbacks for the sticky notes windows */
-gboolean stickynote_toggle_lock_cb(GtkWidget *widget, StickyNote *note);
-gboolean stickynote_close_cb(GtkWidget *widget, StickyNote *note);
-gboolean stickynote_resize_cb(GtkWidget *widget, GdkEventButton *event, StickyNote *note);
-gboolean stickynote_move_cb(GtkWidget *widget, GdkEventButton *event, StickyNote *note);
-gboolean stickynote_configure_cb(GtkWidget *widget, GdkEventConfigure *event, StickyNote *note);
-gboolean stickynote_delete_cb(GtkWidget *widget, GdkEvent *event, StickyNote *note);
-gboolean stickynote_show_popup_menu(GtkWidget *widget, GdkEventButton *event, GtkWidget *popup_menu);
+gboolean
+stickynote_toggle_lock_cb (GtkWidget *widget,
+ StickyNote *note);
+gboolean
+stickynote_close_cb (GtkWidget *widget,
+ StickyNote *note);
+gboolean
+stickynote_resize_cb (GtkWidget *widget,
+ GdkEventButton *event,
+ StickyNote *note);
+gboolean
+stickynote_move_cb (GtkWidget *widget,
+ GdkEventButton *event,
+ StickyNote *note);
+gboolean
+stickynote_configure_cb (GtkWidget *widget,
+ GdkEventConfigure *event,
+ StickyNote *note);
+gboolean
+stickynote_delete_cb (GtkWidget *widget,
+ GdkEvent *event,
+ StickyNote *note);
+gboolean
+stickynote_show_popup_menu (GtkWidget *widget,
+ GdkEventButton *event,
+ GtkWidget *popup_menu);
/* Callbacks for the sticky notes popup menu */
-void popup_create_cb(GtkWidget *widget, StickyNote *note);
-void popup_destroy_cb(GtkWidget *widget, StickyNote *note);
-void popup_toggle_lock_cb(GtkToggleAction *action, StickyNote *note);
-void popup_properties_cb(GtkWidget *widget, StickyNote *note);
+void
+popup_create_cb (GtkWidget *widget,
+ StickyNote *note);
+void
+popup_destroy_cb (GtkWidget *widget,
+ StickyNote *note);
+void
+popup_toggle_lock_cb (GtkToggleAction *action,
+ StickyNote *note);
+void
+popup_properties_cb (GtkWidget *widget,
+ StickyNote *note);
/* Callbacks for sticky notes properties dialog */
-void properties_apply_title_cb(StickyNote *note);
-void properties_apply_color_cb(StickyNote *note);
-void properties_apply_font_cb(StickyNote *note);
-void properties_color_cb(GtkWidget *button, StickyNote *note);
-void properties_font_cb(GtkWidget *button, StickyNote *note);
-void properties_activate_cb(GtkWidget *widget, StickyNote *note);
+void
+properties_apply_title_cb (StickyNote *note);
+void
+properties_apply_color_cb (StickyNote *note);
+void
+properties_apply_font_cb (StickyNote *note);
+void
+properties_color_cb (GtkWidget *button,
+ StickyNote *note);
+void
+properties_font_cb (GtkWidget *button,
+ StickyNote *note);
+void
+properties_activate_cb (GtkWidget *widget,
+ StickyNote *note);
#endif /* __STICKYNOTES_CALLBACKS_H__ */
diff --git a/stickynotes/util.c b/stickynotes/util.c
index d8e370c4..b5faf292 100644
--- a/stickynotes/util.c
+++ b/stickynotes/util.c
@@ -29,97 +29,98 @@
static Atom
xstuff_atom_get (const char *atom_name)
{
- static GHashTable *atom_hash;
- Display *xdisplay;
- Atom retval;
+ static GHashTable *atom_hash;
+ Display *xdisplay;
+ Atom retval;
- g_return_val_if_fail (atom_name != NULL, None);
+ g_return_val_if_fail (atom_name != NULL, None);
- xdisplay = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
+ xdisplay = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
- if (!atom_hash)
- atom_hash = g_hash_table_new_full (
- g_str_hash, g_str_equal, g_free, NULL);
+ if (!atom_hash)
+ atom_hash = g_hash_table_new_full (g_str_hash,
+ g_str_equal,
+ g_free, NULL);
- retval = GPOINTER_TO_UINT (g_hash_table_lookup (atom_hash, atom_name));
- if (!retval) {
- retval = XInternAtom (xdisplay, atom_name, FALSE);
+ retval = GPOINTER_TO_UINT (g_hash_table_lookup (atom_hash, atom_name));
+ if (!retval) {
+ retval = XInternAtom (xdisplay, atom_name, FALSE);
- if (retval != None)
- g_hash_table_insert (atom_hash, g_strdup (atom_name),
- GUINT_TO_POINTER (retval));
- }
+ if (retval != None)
+ g_hash_table_insert (atom_hash, g_strdup (atom_name),
+ GUINT_TO_POINTER (retval));
+ }
- return retval;
+ return retval;
}
int
xstuff_get_current_workspace (GtkWindow *window)
{
- Window root_window;
- Atom type = None;
- gulong nitems;
- gulong bytes_after;
- gulong *num;
- int format;
- int result;
- int retval;
- GdkDisplay *gdk_display;
- Display *xdisplay;
-
- root_window = GDK_WINDOW_XID (gtk_widget_get_window (GTK_WIDGET (window)));
+ Window root_window;
+ Atom type = None;
+ gulong nitems;
+ gulong bytes_after;
+ gulong *num;
+ int format;
+ int result;
+ int retval;
+ GdkDisplay *gdk_display;
+ Display *xdisplay;
+
+ root_window = GDK_WINDOW_XID (gtk_widget_get_window (GTK_WIDGET (window)));
gdk_display = gdk_display_get_default ();
- xdisplay = GDK_DISPLAY_XDISPLAY (gdk_display);
-
- gdk_x11_display_error_trap_push (gdk_display);
- result = XGetWindowProperty (xdisplay,
- root_window,
- xstuff_atom_get ("_NET_CURRENT_DESKTOP"),
- 0, G_MAXLONG,
- False, XA_CARDINAL,
- &type, &format, &nitems,
- &bytes_after, (gpointer) &num);
- if (gdk_x11_display_error_trap_pop (gdk_display) || result != Success)
- return -1;
-
- if (type != XA_CARDINAL) {
- XFree (num);
- return -1;
- }
-
- retval = *num;
-
- XFree (num);
-
- return retval;
+ xdisplay = GDK_DISPLAY_XDISPLAY (gdk_display);
+
+ gdk_x11_display_error_trap_push (gdk_display);
+ result = XGetWindowProperty (xdisplay,
+ root_window,
+ xstuff_atom_get ("_NET_CURRENT_DESKTOP"),
+ 0, G_MAXLONG,
+ False, XA_CARDINAL,
+ &type, &format, &nitems,
+ &bytes_after, (gpointer) &num);
+ if (gdk_x11_display_error_trap_pop (gdk_display) || result != Success)
+ return -1;
+
+ if (type != XA_CARDINAL) {
+ XFree (num);
+ return -1;
+ }
+
+ retval = *num;
+
+ XFree (num);
+
+ return retval;
}
void
xstuff_change_workspace (GtkWindow *window,
int new_space)
{
- XEvent xev;
- Window xwindow;
- Display *gdk_display;
- Screen *screen;
-
- gdk_display = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
- xwindow = GDK_WINDOW_XID (GDK_WINDOW (gtk_widget_get_window (GTK_WIDGET (window))));
- screen = GDK_SCREEN_XSCREEN (gtk_widget_get_screen (GTK_WIDGET (window)));
-
- xev.xclient.type = ClientMessage;
- xev.xclient.serial = 0;
- xev.xclient.send_event = True;
- xev.xclient.display = gdk_display;
- xev.xclient.window = xwindow;
- xev.xclient.message_type = xstuff_atom_get ("_NET_WM_DESKTOP");
- xev.xclient.format = 32;
- xev.xclient.data.l[0] = new_space;
- xev.xclient.data.l[1] = 0;
- xev.xclient.data.l[2] = 0;
-
- XSendEvent (gdk_display,
- RootWindowOfScreen (screen),
- False,
- SubstructureRedirectMask | SubstructureNotifyMask,
- &xev);
+ XEvent xev;
+ Window xwindow;
+ Display *gdk_display;
+ Screen *screen;
+
+ gdk_display = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
+ xwindow = GDK_WINDOW_XID (GDK_WINDOW (gtk_widget_get_window (GTK_WIDGET (window))));
+ screen = GDK_SCREEN_XSCREEN (gtk_widget_get_screen (GTK_WIDGET (window)));
+
+ xev.xclient.type = ClientMessage;
+ xev.xclient.serial = 0;
+ xev.xclient.send_event = True;
+ xev.xclient.display = gdk_display;
+ xev.xclient.window = xwindow;
+ xev.xclient.message_type = xstuff_atom_get ("_NET_WM_DESKTOP");
+ xev.xclient.format = 32;
+ xev.xclient.data.l[0] = new_space;
+ xev.xclient.data.l[1] = 0;
+ xev.xclient.data.l[2] = 0;
+
+ XSendEvent (gdk_display,
+ RootWindowOfScreen (screen),
+ False,
+ SubstructureRedirectMask | SubstructureNotifyMask,
+ &xev);
}
diff --git a/stickynotes/util.h b/stickynotes/util.h
index 61d86c4f..e3724c54 100644
--- a/stickynotes/util.h
+++ b/stickynotes/util.h
@@ -23,8 +23,8 @@
#include <glib.h>
#include <gtk/gtk.h>
-void xstuff_change_workspace (GtkWindow *window,
- int new_space);
-int xstuff_get_current_workspace (GtkWindow *window);
+void xstuff_change_workspace (GtkWindow *window,
+ int new_space);
+int xstuff_get_current_workspace (GtkWindow *window);
#endif /* #ifndef __UTIL_H__ */