[gnome-calendar] project: remove libgd dependency



commit a5c65af0fbbb4a750091274932633b790c76d67f
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Tue Oct 7 14:47:51 2014 -0300

    project: remove libgd dependency
    
    This patch fixes bug #737729, removing all libgd dependencies.
    
    Every GdHeaderButton was replaced by GtkButton, and GdNotification was replaced by a custom-styled 
GtkFrame inside a GtkRevealer.

 .gitmodules       |    3 -
 Makefile.am       |    4 +-
 autogen.sh        |    1 -
 configure.ac      |    8 ---
 libgd             |    1 -
 src/Makefile.am   |    2 -
 src/gcal-window.c |  143 ++++++++++++++++++++++++++++++++++++-----------------
 7 files changed, 100 insertions(+), 62 deletions(-)
---
diff --git a/.gitmodules b/.gitmodules
index bfd964e..e69de29 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,3 +0,0 @@
-[submodule "libgd"]
-       path = libgd
-       url = git://git.gnome.org/libgd
diff --git a/Makefile.am b/Makefile.am
index 0b9b1b2..089b942 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,6 +1,6 @@
-ACLOCAL_AMFLAGS = -I m4 -I libgd ${ACLOCAL_FLAGS}
+ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
 
-SUBDIRS = libgd src data po
+SUBDIRS = src data po
 
 gnome_calendardocdir = ${datadir}/doc/${PACKAGE_NAME}-${PACKAGE_VERSION}
 gnome_calendardoc_DATA =        \
diff --git a/autogen.sh b/autogen.sh
index 82ea148..55aedb6 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -5,7 +5,6 @@ srcdir=`dirname $0`
 test -z "$srcdir" && srcdir=.
 
 PKG_NAME="gnome-calendar"
-ACLOCAL_FLAGS="-I libgd $ACLOCAL_FLAGS"
 
 (test -f $srcdir/configure.ac \
   && test -d $srcdir/src) || {
diff --git a/configure.ac b/configure.ac
index c789e08..3e7d23f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -96,16 +96,8 @@ PKG_CHECK_MODULES(CALENDAR,
                   libedataserver-1.2 >= $EDATASERVER_REQUIRED
                   libical >= $LIBICAL_REQUIRED)
 
-LIBGD_INIT([
-  _header-button
-  notification
-  static
-  tagged-entry
-])
-
 AC_CONFIG_FILES([
       Makefile
-      libgd/Makefile
       src/Makefile
       data/Makefile
       data/gnome-calendar.desktop.in
diff --git a/src/Makefile.am b/src/Makefile.am
index e170371..d07d34a 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -3,7 +3,6 @@ AM_CPPFLAGS =                                             \
     -DPACKAGE_SRC_DIR=\""$(srcdir)"\"                     \
     -DPACKAGE_DATA_DIR=\""$(pkgdatadir)"\"                \
     -DUI_DATA_DIR=\""$(pkgdatadir)/style"\"               \
-    -I$(top_srcdir)/libgd                                 \
     $(MAINTAINER_COMPILER_FLAGS)                          \
     $(WARN_CFLAGS)                                        \
     -DEDS_DISABLE_DEPRECATED                              \
@@ -66,7 +65,6 @@ gnome_calendar_LDFLAGS =                                  \
 
 gnome_calendar_LDADD =                                    \
   -lm                                                     \
-  $(top_builddir)/libgd/libgd.la                          \
   $(CALENDAR_LIBS)
 
 resource_files = $(shell glib-compile-resources --sourcedir=$(top_srcdir)/data --generate-dependencies 
$(top_srcdir)/data/calendar.gresource.xml)
diff --git a/src/gcal-window.c b/src/gcal-window.c
index b13cea7..9335bc9 100644
--- a/src/gcal-window.c
+++ b/src/gcal-window.c
@@ -35,8 +35,6 @@
 
 #include "e-cell-renderer-color.h"
 
-#include <libgd/gd.h>
-
 #include <glib/gi18n.h>
 
 #include <libecal/libecal.h>
@@ -65,8 +63,8 @@ typedef struct
   GtkWidget           *nav_bar;
   GtkWidget           *views_overlay;
   GtkWidget           *views_stack;
+  GtkWidget           *notification;
   GtkWidget           *new_event_widget;
-  GtkWidget           *noty; /* short-lived */
   GtkWidget           *popover; /* short-lived */
 
   /* header_bar widets */
@@ -141,6 +139,11 @@ static void           close_new_event_widget             (GtkButton           *b
 
 static GcalManager*   get_manager                        (GcalWindow          *window);
 
+static void           create_notification                (GcalWindow          *window);
+
+static void           hide_notification                  (GtkWidget           *button,
+                                                          gpointer             user_data);
+
 /* handling events interaction */
 static void           create_event                       (gpointer             user_data,
                                                           GtkWidget           *widget);
@@ -199,7 +202,8 @@ static void           gcal_window_event_created          (GcalManager         *m
                                                           const gchar         *event_uid,
                                                           gpointer             user_data);
 
-static void           gcal_window_remove_event           (GdNotification      *notification,
+static void           gcal_window_remove_event           (GtkWidget           *notification,
+                                                          GParamSpec          *spec,
                                                           gpointer             user_data);
 
 static void           gcal_window_undo_remove_event      (GtkButton           *button,
@@ -633,6 +637,77 @@ get_manager (GcalWindow *window)
 }
 
 static void
+create_notification (GcalWindow *window)
+{
+  GcalWindowPrivate *priv;
+
+  GtkWidget *notification_frame;
+  GtkWidget *notification_grid;
+  GtkWidget *undo_button;
+  GtkWidget *hide_button;
+
+  priv = gcal_window_get_instance_private (window);
+
+  priv->notification = gtk_revealer_new ();
+  gtk_revealer_set_transition_type (
+      GTK_REVEALER (priv->notification),
+      GTK_REVEALER_TRANSITION_TYPE_SLIDE_DOWN);
+  gtk_revealer_set_transition_duration (GTK_REVEALER (priv->notification), 100);
+  gtk_widget_set_halign (priv->notification, GTK_ALIGN_CENTER);
+  gtk_widget_set_valign (priv->notification, GTK_ALIGN_START);
+
+  gtk_overlay_add_overlay (GTK_OVERLAY (priv->views_overlay),
+                           priv->notification);
+
+  notification_frame = gtk_frame_new (NULL);
+  gtk_style_context_add_class (
+      gtk_widget_get_style_context (notification_frame),
+      "app-notification");
+
+  /* notification content */
+  notification_grid = gtk_grid_new ();
+  gtk_grid_set_column_spacing (GTK_GRID (notification_grid), 20);
+
+  undo_button = gtk_button_new_with_label (_("Undo"));
+  gtk_widget_set_valign (undo_button, GTK_ALIGN_CENTER);
+
+  hide_button = gtk_button_new_from_icon_name ("window-close-symbolic", GTK_ICON_SIZE_MENU);
+  gtk_button_set_relief (GTK_BUTTON (hide_button), GTK_RELIEF_NONE);
+  gtk_style_context_add_class (
+      gtk_widget_get_style_context (hide_button),
+      "image-button");
+
+  gtk_container_add (GTK_CONTAINER (notification_grid), gtk_label_new (_("Event deleted")));
+  gtk_container_add (GTK_CONTAINER (notification_grid), undo_button);
+  gtk_container_add (GTK_CONTAINER (notification_grid), hide_button);
+
+  gtk_container_add (GTK_CONTAINER (notification_frame), notification_grid);
+  gtk_container_add (GTK_CONTAINER (priv->notification), notification_frame);
+
+  gtk_widget_show_all (priv->notification);
+
+  g_signal_connect (hide_button,
+                    "clicked",
+                    G_CALLBACK (hide_notification),
+                    window);
+  g_signal_connect (priv->notification,
+                    "notify::child-revealed",
+                    G_CALLBACK (gcal_window_remove_event),
+                    window);
+  g_signal_connect (undo_button,
+                    "clicked",
+                    G_CALLBACK (gcal_window_undo_remove_event),
+                    window);
+}
+
+static void
+hide_notification (GtkWidget *button,
+                   gpointer   user_data)
+{
+  gcal_window_hide_notification (GCAL_WINDOW (user_data));
+}
+
+static void
 create_event (gpointer   user_data,
               GtkWidget *widget)
 {
@@ -714,9 +789,6 @@ edit_dialog_closed (GtkDialog *dialog,
   GcalEditDialog *edit_dialog;
   GcalView *view;
 
-  GtkWidget *grid;
-  GtkWidget *undo_button;
-
   priv = gcal_window_get_instance_private (GCAL_WINDOW (user_data));
 
   gtk_widget_hide (GTK_WIDGET (dialog));
@@ -729,30 +801,12 @@ edit_dialog_closed (GtkDialog *dialog,
     {
     case GCAL_RESPONSE_DELETE_EVENT:
       /* delete the event */
-      if (priv->noty != NULL)
-        g_clear_object (&(priv->noty));
-
-      priv->noty = gd_notification_new ();
-      grid = gtk_grid_new ();
-      gtk_grid_set_column_spacing (GTK_GRID (grid), 12);
-      gtk_container_add (GTK_CONTAINER (grid),
-                         gtk_label_new (_("Event deleted")));
+      if (priv->notification != NULL)
+        g_clear_object (&(priv->notification));
 
-      undo_button = gtk_button_new_with_label (_("Undo"));
-      gtk_container_add (GTK_CONTAINER (grid), undo_button);
-
-      gtk_container_add (GTK_CONTAINER (priv->noty), grid);
+      create_notification (GCAL_WINDOW (user_data));
       gcal_window_show_notification (GCAL_WINDOW (user_data));
 
-      g_signal_connect (priv->noty,
-                        "dismissed",
-                        G_CALLBACK (gcal_window_remove_event),
-                        user_data);
-      g_signal_connect (undo_button,
-                        "clicked",
-                        G_CALLBACK (gcal_window_undo_remove_event),
-                        user_data);
-
       priv->event_to_delete =
         gcal_edit_dialog_get_event_uuid (edit_dialog);
 
@@ -854,9 +908,7 @@ gcal_window_constructed (GObject *object)
   priv->header_bar = gtk_header_bar_new ();
 
   /* header_bar: new */
-  priv->new_button = gd_header_simple_button_new ();
-  gd_header_button_set_label (GD_HEADER_BUTTON (priv->new_button),
-                              _("New Event"));
+  priv->new_button = gtk_button_new_with_label (_("New Event"));
   gtk_style_context_add_class (
       gtk_widget_get_style_context (priv->new_button),
       "suggested-action");
@@ -868,17 +920,14 @@ gcal_window_constructed (GObject *object)
                                    priv->views_switcher);
 
   /* header_bar: menu */
-  menu_button = gd_header_menu_button_new ();
-  gd_header_button_set_label (GD_HEADER_BUTTON (menu_button),
-                              _("Settings"));
-  gd_header_button_set_symbolic_icon_name (GD_HEADER_BUTTON (menu_button),
-                                           "open-menu-symbolic");
+  menu_button = gtk_button_new_from_icon_name ("open-menu-symbolic", GTK_ICON_SIZE_MENU);
   gtk_header_bar_pack_end (GTK_HEADER_BAR (priv->header_bar), menu_button);
 
   /* header_bar: search */
-  search_button = gd_header_toggle_button_new ();
-  gd_header_button_set_symbolic_icon_name (GD_HEADER_BUTTON (search_button),
-                                           "edit-find-symbolic");
+  search_button = gtk_toggle_button_new ();
+  gtk_container_add (
+      GTK_CONTAINER (search_button),
+      gtk_image_new_from_icon_name ("edit-find-symbolic", GTK_ICON_SIZE_MENU));
   gtk_header_bar_pack_end (GTK_HEADER_BAR (priv->header_bar), search_button);
 
   gtk_header_bar_set_show_close_button (GTK_HEADER_BAR (priv->header_bar),
@@ -1323,7 +1372,8 @@ gcal_window_event_created (GcalManager *manager,
 }
 
 static void
-gcal_window_remove_event (GdNotification  *notification,
+gcal_window_remove_event (GtkWidget       *notification,
+                          GParamSpec      *spec,
                           gpointer         user_data)
 {
   GcalWindowPrivate *priv;
@@ -1332,6 +1382,9 @@ gcal_window_remove_event (GdNotification  *notification,
 
   priv = gcal_window_get_instance_private (GCAL_WINDOW (user_data));
 
+  if (gtk_revealer_get_child_revealed (GTK_REVEALER (notification)))
+      return;
+
   if (priv->event_to_delete != NULL)
     {
       manager = get_manager (GCAL_WINDOW (user_data));
@@ -1345,7 +1398,7 @@ gcal_window_remove_event (GdNotification  *notification,
     }
 
   /* since this is called when the notification is dismissed is safe to do here: */
-  priv->noty = NULL;
+  gtk_widget_destroy (priv->notification);
 }
 
 static void
@@ -1496,9 +1549,8 @@ gcal_window_show_notification (GcalWindow *window)
   GcalWindowPrivate *priv;
 
   priv = gcal_window_get_instance_private (window);
-  gtk_overlay_add_overlay (GTK_OVERLAY (priv->views_overlay),
-                           priv->noty);
-  gtk_widget_show_all (priv->noty);
+
+  gtk_revealer_set_reveal_child (GTK_REVEALER (priv->notification), TRUE);
 }
 
 void
@@ -1507,5 +1559,6 @@ gcal_window_hide_notification (GcalWindow *window)
   GcalWindowPrivate *priv;
 
   priv = gcal_window_get_instance_private (window);
-  gd_notification_dismiss (GD_NOTIFICATION (priv->noty));
+
+  gtk_revealer_set_reveal_child (GTK_REVEALER (priv->notification), FALSE);
 }


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