[gnome-applets] sticky-notes: move notes callbacks to sticky-notes.c



commit 16332064595eaeaf9d2391a76c57a52e7ed28a02
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Tue Apr 7 00:22:33 2020 +0300

    sticky-notes: move notes callbacks to sticky-notes.c

 gnome-applets/sticky-notes/Makefile.am             |   2 -
 .../sticky-notes/sticky-notes-callbacks.c          | 246 ---------------------
 .../sticky-notes/sticky-notes-callbacks.h          |  57 -----
 gnome-applets/sticky-notes/sticky-notes.c          | 209 ++++++++++++++++-
 po/POTFILES.in                                     |   1 -
 5 files changed, 208 insertions(+), 307 deletions(-)
---
diff --git a/gnome-applets/sticky-notes/Makefile.am b/gnome-applets/sticky-notes/Makefile.am
index acf540ad6..c6bf5bcb0 100644
--- a/gnome-applets/sticky-notes/Makefile.am
+++ b/gnome-applets/sticky-notes/Makefile.am
@@ -24,8 +24,6 @@ libsticky_notes_applet_la_SOURCES = \
        sticky-notes-applet.h \
        sticky-notes-applet-callbacks.c \
        sticky-notes-applet-callbacks.h \
-       sticky-notes-callbacks.c \
-       sticky-notes-callbacks.h \
        sticky-notes-preferences.c \
        sticky-notes-preferences.h \
        util.c \
diff --git a/gnome-applets/sticky-notes/sticky-notes.c b/gnome-applets/sticky-notes/sticky-notes.c
index 288b4f174..5abbef053 100644
--- a/gnome-applets/sticky-notes/sticky-notes.c
+++ b/gnome-applets/sticky-notes/sticky-notes.c
@@ -26,7 +26,6 @@
 #include <libwnck/libwnck.h>
 #include <string.h>
 
-#include "sticky-notes-callbacks.h"
 #include "util.h"
 #include "sticky-notes-applet.h"
 #include "gsettings.h"
@@ -40,6 +39,54 @@ static gboolean save_scheduled = FALSE;
 
 static void response_cb (GtkWidget *dialog, gint id, gpointer data);
 
+static void
+popup_create_cb (GSimpleAction *action,
+                 GVariant      *parameter,
+                 gpointer       user_data)
+{
+       StickyNote *note = (StickyNote *) user_data;
+       stickynotes_add (gtk_widget_get_screen (note->w_window));
+}
+
+static void
+popup_destroy_cb (GSimpleAction *action,
+                  GVariant      *parameter,
+                  gpointer       user_data)
+{
+       StickyNote *note = (StickyNote *) user_data;
+       stickynotes_remove (note);
+}
+
+static void
+popup_toggle_lock_cb (GSimpleAction *action,
+                      GVariant      *parameter,
+                      gpointer       user_data)
+{
+       GVariant *state = g_action_get_state (G_ACTION (action));
+       g_action_change_state (G_ACTION (action), g_variant_new_boolean (!g_variant_get_boolean (state)));
+       g_variant_unref (state);
+}
+
+static void
+popup_toggle_lock_state (GSimpleAction *action,
+                         GVariant      *value,
+                         gpointer       user_data)
+{
+       StickyNote *note = (StickyNote *) user_data;
+       gboolean locked = g_variant_get_boolean (value);
+
+       stickynote_set_locked (note, locked);
+}
+
+static void
+popup_properties_cb (GSimpleAction *action,
+                     GVariant      *parameter,
+                     gpointer       user_data)
+{
+       StickyNote *note = (StickyNote *) user_data;
+       stickynote_change_properties (note);
+}
+
 /* Popup menu on the sticky note */
 static const GActionEntry stickynotes_note_menu_actions [] = {
        { "create",     popup_create_cb,      NULL, NULL,    NULL },
@@ -125,6 +172,166 @@ set_icon_geometry  (GdkWindow *window,
                        (guchar *)&data, 4);
 }
 
+static gboolean
+stickynote_show_popup_menu (GtkWidget      *widget,
+                            GdkEventButton *event,
+                            GtkWidget      *popup_menu)
+{
+       if (event->type == GDK_BUTTON_PRESS && event->button == 3)
+       {
+               gtk_menu_popup (GTK_MENU (popup_menu),
+                               NULL, NULL,
+                               NULL, NULL,
+                               event->button, event->time);
+       }
+
+       return FALSE;
+}
+
+static gboolean
+stickynote_toggle_lock_cb (GtkWidget  *widget,
+                           StickyNote *note)
+{
+       stickynote_set_locked (note, !note->locked);
+
+       return TRUE;
+}
+
+static gboolean
+stickynote_close_cb (GtkWidget  *widget,
+                     StickyNote *note)
+{
+       stickynotes_remove (note);
+
+       return TRUE;
+}
+
+static 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;
+}
+
+static 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;
+
+       return TRUE;
+}
+
+static 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;
+
+       stickynotes_save();
+
+       return FALSE;
+}
+
+static gboolean
+stickynote_delete_cb (GtkWidget  *widget,
+                      GdkEvent   *event,
+                      StickyNote *note)
+{
+       stickynotes_remove(note);
+
+       return TRUE;
+}
+
+static void
+properties_apply_title_cb (StickyNote *note)
+{
+       stickynote_set_title (note, gtk_entry_get_text (GTK_ENTRY (note->w_entry)));
+}
+
+static 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;
+               GdkRGBA 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);
+       }
+
+       stickynote_set_color (note, color_str, font_color_str, TRUE);
+
+       g_free (color_str);
+       g_free (font_color_str);
+}
+
+static void
+properties_color_cb (GtkWidget  *button,
+                     StickyNote *note)
+{
+       properties_apply_color_cb (note);
+}
+
+static void
+properties_font_cb (GtkWidget  *button,
+                    StickyNote *note)
+{
+       const gchar *font_str;
+
+       font_str = gtk_font_button_get_font_name (GTK_FONT_BUTTON (button));
+
+       stickynote_set_font (note, font_str, TRUE);
+}
+
+static 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));
+
+       stickynote_set_font (note, font_str, TRUE);
+}
+
+static void
+properties_activate_cb (GtkWidget  *widget,
+                        StickyNote *note)
+{
+       gtk_dialog_response (GTK_DIALOG (note->w_properties), GTK_RESPONSE_CLOSE);
+}
+
 /* Called when a timeout occurs.  */
 static gboolean
 timeout_happened (gpointer data)
diff --git a/po/POTFILES.in b/po/POTFILES.in
index b21b67318..21a2a1fc7 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -60,7 +60,6 @@ gnome-applets/netspeed/netspeed-applet.c
 gnome-applets/netspeed/preferences.c
 gnome-applets/sticky-notes/sticky-notes-applet.c
 gnome-applets/sticky-notes/sticky-notes-applet-callbacks.c
-gnome-applets/sticky-notes/sticky-notes-callbacks.c
 gnome-applets/sticky-notes/sticky-notes.c
 gnome-applets/sticky-notes/ui/sticky-notes-applet-menu.ui
 gnome-applets/sticky-notes/ui/sticky-notes-delete-all.ui


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]