Commit 4977aef3 authored by Alberts Muktupāvels's avatar Alberts Muktupāvels

sticky-notes: per-applet preferences dialog

parent ef9ccb24
......@@ -416,27 +416,3 @@ void preferences_apply_cb (GSettings *settings,
stickynotes_applet_update_menus();
}
/* Preferences Callback : Response. */
void preferences_response_cb(GtkWidget *dialog, gint response, gpointer data)
{
if (response == GTK_RESPONSE_HELP) {
GError *error = NULL;
gtk_show_uri (gtk_widget_get_screen (GTK_WIDGET (dialog)),
"help: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_destroy(GTK_WIDGET(dialog));
}
......@@ -39,6 +39,5 @@ void menu_toggle_lock_state(GSimpleAction *action, GVariant *value, gpointer use
/* Callbacks for sticky notes preferences dialog */
void preferences_apply_cb(GSettings *settings, const gchar *key, gpointer user_data);
void preferences_response_cb(GtkWidget *dialog, gint response, gpointer data);
#endif /* __STICKYNOTES_APPLET_CALLBACKS_H__ */
......@@ -35,27 +35,42 @@ StickyNotes *stickynotes = NULL;
static void sticky_notes_init (GpApplet *applet);
static void sticky_notes_applet_new (StickyNotesApplet *self);
static void
preferences_response_cb (GtkWidget *widget,
gint response_id,
StickyNotesApplet *self)
{
if (response_id == GTK_RESPONSE_HELP)
gp_applet_show_help (GP_APPLET (self), "stickynotes-advanced-settings");
else if (response_id == GTK_RESPONSE_CLOSE)
gtk_widget_destroy (widget);
}
static void
menu_preferences_cb (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
if (stickynotes->w_prefs != NULL)
StickyNotesApplet *self;
self = STICKY_NOTES_APPLET (user_data);
if (self->w_prefs != NULL)
{
gtk_window_present (GTK_WINDOW (stickynotes->w_prefs));
gtk_window_present (GTK_WINDOW (self->w_prefs));
return;
}
stickynotes->w_prefs = sticky_notes_preferences_new (stickynotes->settings);
g_object_add_weak_pointer (G_OBJECT (stickynotes->w_prefs),
(gpointer *) &stickynotes->w_prefs);
self->w_prefs = sticky_notes_preferences_new (stickynotes->settings);
g_object_add_weak_pointer (G_OBJECT (self->w_prefs),
(gpointer *) &self->w_prefs);
g_signal_connect (stickynotes->w_prefs,
g_signal_connect (self->w_prefs,
"response",
G_CALLBACK (preferences_response_cb),
NULL);
self);
gtk_window_present (GTK_WINDOW (stickynotes->w_prefs));
gtk_window_present (GTK_WINDOW (self->w_prefs));
}
static void
......@@ -107,6 +122,18 @@ sticky_notes_applet_constructed (GObject *object)
sticky_notes_applet_setup (STICKY_NOTES_APPLET (object));
}
static void
sticky_notes_applet_dispose (GObject *object)
{
StickyNotesApplet *self;
self = STICKY_NOTES_APPLET (object);
g_clear_pointer (&self->w_prefs, gtk_widget_destroy);
G_OBJECT_CLASS (sticky_notes_applet_parent_class)->dispose (object);
}
static void
sticky_notes_applet_class_init (StickyNotesAppletClass *self_class)
{
......@@ -115,6 +142,7 @@ sticky_notes_applet_class_init (StickyNotesAppletClass *self_class)
object_class = G_OBJECT_CLASS (self_class);
object_class->constructed = sticky_notes_applet_constructed;
object_class->dispose = sticky_notes_applet_dispose;
}
static void
......
......@@ -32,8 +32,6 @@ G_DECLARE_FINAL_TYPE (StickyNotesApplet, sticky_notes_applet,
/* Global Sticky Notes instance */
typedef struct
{
GtkWidget *w_prefs; /* The prefs dialog */
GList *notes; /* Linked-List of all the sticky notes */
GList *applets; /* Linked-List of all the applets */
......@@ -64,6 +62,8 @@ struct _StickyNotesApplet
GtkOrientation panel_orient;
GtkWidget *menu_tip;
GtkWidget *w_prefs;
};
typedef enum
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment