summaryrefslogtreecommitdiff
path: root/stickynotes
diff options
context:
space:
mode:
authorCallum McKenzie <callum@spooky-possum.org>2009-06-03 18:52:18 +1200
committerCallum McKenzie <callum@spooky-possum.org>2009-06-03 18:58:51 +1200
commit27e658cc1af78b1c1613b991d9b60a9cfcdb537b (patch)
tree701c58549e9fdb8cd2baba3daf3807d9cee3cdb4 /stickynotes
parent765741b65d0c69fc3de6d113aae88b32b22e6128 (diff)
stickynotes: Don't close the prefs dialogs when a check-mark is toggled
Patch contributed by Sergey Rudchenko (gnome bug #567477 and launchpad bug 292536). The patch makes sure that the dialog only closes on a response of GTK_RESPONSE_CLOSE (the delete signal is handled elsewhere so we can ignore GTK_RESPONSE_DELETE_EVENT).
Diffstat (limited to 'stickynotes')
-rw-r--r--stickynotes/stickynotes.c78
-rw-r--r--stickynotes/stickynotes_applet_callbacks.c32
2 files changed, 55 insertions, 55 deletions
diff --git a/stickynotes/stickynotes.c b/stickynotes/stickynotes.c
index fab5f8743..5844434cf 100644
--- a/stickynotes/stickynotes.c
+++ b/stickynotes/stickynotes.c
@@ -76,7 +76,7 @@ static void
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_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
@@ -87,7 +87,7 @@ buffer_changed (GtkTextBuffer *buffer, StickyNote *note)
GUINT_TO_POINTER (stickynotes->last_timeout_data));
}
-/* Create a new (empty) Sticky Note at a specific position
+/* Create a new (empty) Sticky Note at a specific position
and with specific size */
StickyNote *
stickynote_new_aux (GdkScreen *screen, gint x, gint y, gint w, gint h)
@@ -120,7 +120,7 @@ stickynote_new_aux (GdkScreen *screen, gint x, gint y, gint w, gint h)
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,
@@ -133,11 +133,11 @@ stickynote_new_aux (GdkScreen *screen, gint x, gint y, gint w, gint h)
/* 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);
@@ -208,7 +208,7 @@ stickynote_new_aux (GdkScreen *screen, gint x, gint y, gint w, gint h)
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
+ /* 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.
*/
@@ -254,7 +254,7 @@ stickynote_new_aux (GdkScreen *screen, gint x, gint y, gint w, gint h)
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);
@@ -310,7 +310,7 @@ void stickynote_free(StickyNote *note)
g_free(note->color);
g_free(note->font);
-
+
g_free(note);
}
@@ -380,7 +380,7 @@ response_cb (GtkWidget *dialog, gint id, gpointer data)
"ghelp:stickynotes_applet?stickynotes-settings-individual",
gtk_get_current_event_time (),
NULL);
- else
+ else if (id == GTK_RESPONSE_CLOSE)
gtk_widget_hide (dialog);
}
@@ -430,7 +430,7 @@ stickynote_set_color (StickyNote *note,
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 ?
@@ -445,7 +445,7 @@ stickynote_set_color (StickyNote *note,
gtk_widget_set_sensitive (note->w_font_color,
note->color != NULL);
}
-
+
/* If "force_default" is enabled or color_str is NULL,
* then we use the default color instead of color_str. */
if (!color_str || gconf_client_get_bool (stickynotes->gconf,
@@ -489,11 +489,11 @@ stickynote_set_color (StickyNote *note,
/* Make 4 shades of the color, getting darker from the
* original, plus black and white */
gint i;
-
+
for (i = 0; i <= 3; i++)
{
gdk_color_parse (color_str_actual, &colors[i]);
-
+
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;
@@ -523,7 +523,7 @@ stickynote_set_color (StickyNote *note,
rc_style->color_flags[GTK_STATE_NORMAL] = 0;
rc_style->color_flags[GTK_STATE_ACTIVE] = 0;
}
-
+
g_object_ref (G_OBJECT (rc_style));
/* Apply the style to the widgets */
@@ -535,15 +535,15 @@ stickynote_set_color (StickyNote *note,
gtk_widget_modify_style (note->w_close, rc_style);
gtk_widget_modify_style (note->w_resize_se, rc_style);
gtk_widget_modify_style (note->w_resize_sw, rc_style);
-
+
g_object_unref (G_OBJECT (rc_style));
-
+
if (font_color_str_actual)
{
GdkColor font_color;
gdk_color_parse (font_color_str_actual, &font_color);
-
+
gtk_widget_modify_text (note->w_window,
GTK_STATE_NORMAL, &font_color);
gtk_widget_modify_text (note->w_window,
@@ -585,7 +585,7 @@ stickynote_set_font (StickyNote *note, const gchar *font_str, gboolean save)
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 || gconf_client_get_bool (stickynotes->gconf,
@@ -651,7 +651,7 @@ 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);
@@ -700,7 +700,7 @@ stickynote_set_visible (StickyNote *note, gboolean visible)
void stickynotes_add (GdkScreen *screen)
{
StickyNote *note;
-
+
note = stickynote_new (screen);
stickynotes->notes = g_list_append(stickynotes->notes, note);
@@ -729,7 +729,7 @@ void stickynotes_remove(StickyNote *note)
/* Remove the note from the linked-list of all notes */
stickynotes->notes = g_list_remove(stickynotes->notes, note);
-
+
/* Update tooltips */
stickynotes_applet_update_tooltips();
@@ -750,9 +750,9 @@ stickynotes_save_now (void)
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);
@@ -762,7 +762,7 @@ stickynotes_save_now (void)
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;
@@ -774,7 +774,7 @@ stickynotes_save_now (void)
/* 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);
@@ -790,20 +790,20 @@ stickynotes_save_now (void)
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));
+ XML_CHAR (body));
xmlNewProp(node, XML_CHAR ("title"), XML_CHAR (title));
if (note->color)
xmlNewProp (node, XML_CHAR ("color"), XML_CHAR (note->color));
@@ -821,7 +821,7 @@ stickynotes_save_now (void)
if (note->workspace > 0)
{
char *workspace_str;
-
+
workspace_str = g_strdup_printf ("%i",
note->workspace);
xmlNewProp (node, XML_CHAR ("workspace"), XML_CHAR (workspace_str));
@@ -831,7 +831,7 @@ stickynotes_save_now (void)
/* 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);
@@ -846,7 +846,7 @@ stickynotes_save_now (void)
xmlSaveFormatFile(file, doc, 1);
g_free(file);
}
-
+
xmlFreeDoc(doc);
save_scheduled = FALSE;
@@ -887,7 +887,7 @@ stickynotes_load (GdkScreen *screen)
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")))
@@ -896,9 +896,9 @@ stickynotes_load (GdkScreen *screen)
stickynotes_save();
return;
}
-
+
node = root->xmlChildrenNode;
-
+
/* For all children of the root node (ie all sticky notes) */
new_notes = NULL;
new_nodes = NULL;
@@ -925,7 +925,7 @@ stickynotes_load (GdkScreen *screen)
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"));
@@ -965,10 +965,10 @@ stickynotes_load (GdkScreen *screen)
{
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,
@@ -1007,7 +1007,7 @@ stickynotes_load (GdkScreen *screen)
if (body) {
GtkTextBuffer *buffer;
GtkTextIter start, end;
-
+
buffer = gtk_text_view_get_buffer(
GTK_TEXT_VIEW(note->w_body));
gtk_text_buffer_get_bounds(
@@ -1028,7 +1028,7 @@ stickynotes_load (GdkScreen *screen)
g_free(locked);
}
}
-
+
node = node->next;
}
diff --git a/stickynotes/stickynotes_applet_callbacks.c b/stickynotes/stickynotes_applet_callbacks.c
index 54b1b9d99..e6be02551 100644
--- a/stickynotes/stickynotes_applet_callbacks.c
+++ b/stickynotes/stickynotes_applet_callbacks.c
@@ -1,4 +1,4 @@
-/* Sticky Notes
+/* Sticky Notes
* Copyright (C) 2002-2003 Loban A Rahman
*
* This program is free software; you can redistribute it and/or modify
@@ -126,7 +126,7 @@ gboolean applet_cross_cb(GtkWidget *widget, GdkEventCrossing *event, StickyNotes
applet->prelighted = event->type == GDK_ENTER_NOTIFY || GTK_WIDGET_HAS_FOCUS(widget);
stickynotes_applet_update_icon(applet);
-
+
return FALSE;
}
@@ -143,11 +143,11 @@ gboolean applet_focus_cb(GtkWidget *widget, GdkEventFocus *event, StickyNotesApp
static GdkFilterReturn desktop_window_event_filter (GdkXEvent *xevent,
GdkEvent *event,
gpointer data)
-{
+{
if ((((XEvent*)xevent)->xany.type == PropertyNotify) &&
- (((XEvent*)xevent)->xproperty.atom == gdk_x11_get_xatom_by_name ("_NET_WM_USER_TIME"))) {
+ (((XEvent*)xevent)->xproperty.atom == gdk_x11_get_xatom_by_name ("_NET_WM_USER_TIME"))) {
stickynote_show_notes (FALSE);
- }
+ }
return GDK_FILTER_CONTINUE;
}
@@ -239,7 +239,7 @@ applet_change_bg_cb (PanelApplet *panel_applet,
void applet_destroy_cb (PanelApplet *panel_applet, StickyNotesApplet *applet)
{
GList *notes;
-
+
stickynotes_save_now ();
if (applet->destroy_all_dialog != NULL)
@@ -247,7 +247,7 @@ void applet_destroy_cb (PanelApplet *panel_applet, StickyNotesApplet *applet)
if (stickynotes->applets != NULL)
stickynotes->applets = g_list_remove (stickynotes->applets, applet);
-
+
if (stickynotes->applets == NULL) {
notes = stickynotes->notes;
while (notes) {
@@ -256,9 +256,9 @@ void applet_destroy_cb (PanelApplet *panel_applet, StickyNotesApplet *applet)
notes = g_list_next (notes);
}
}
-
-
-}
+
+
+}
/* Destroy all response Callback: Callback for the destroy all dialog */
static void
@@ -269,7 +269,7 @@ destroy_all_response_cb (GtkDialog *dialog, gint id, StickyNotesApplet *applet)
StickyNote *note = g_list_nth_data(stickynotes->notes, 0);
stickynote_free(note);
stickynotes->notes = g_list_remove(stickynotes->notes, note);
- }
+ }
}
stickynotes_applet_update_tooltips();
@@ -306,7 +306,7 @@ void menu_destroy_all_cb(BonoboUIComponent *uic, StickyNotesApplet *applet, cons
gtk_window_present (GTK_WINDOW (applet->destroy_all_dialog));
return;
}
-
+
applet->destroy_all_dialog = GTK_WIDGET (gtk_builder_get_object (builder, "delete_all_dialog"));
g_object_unref (builder);
@@ -442,7 +442,7 @@ preferences_color_cb (GtkWidget *button, gpointer data)
gtk_color_button_get_color (
GTK_COLOR_BUTTON (stickynotes->w_prefs_font_color),
&font_color);
-
+
color_str = g_strdup_printf ("#%.2x%.2x%.2x",
color.red / 256,
color.green / 256,
@@ -451,7 +451,7 @@ preferences_color_cb (GtkWidget *button, gpointer data)
font_color.red / 256,
font_color.green / 256,
font_color.blue / 256);
-
+
gconf_client_set_string (stickynotes->gconf,
GCONF_PATH "/defaults/color", color_str, NULL);
gconf_client_set_string (stickynotes->gconf,
@@ -565,8 +565,8 @@ void preferences_response_cb(GtkWidget *dialog, gint response, gpointer data)
}
}
- else
- gtk_widget_hide(GTK_WIDGET(dialog));
+ else if (response == GTK_RESPONSE_CLOSE)
+ gtk_widget_hide(GTK_WIDGET(dialog));
}
/* Preferences Callback : Delete */