[gnome-photos] Add a helper to set GtkListBox separators and use it everywhere



commit c71402af2eb4d4e6a68f39cfc03809c62c2b0685
Author: Debarshi Ray <debarshir gnome org>
Date:   Tue Jan 5 19:10:11 2016 +0100

    Add a helper to set GtkListBox separators and use it everywhere

 src/photos-dlna-renderers-dialog.c |   22 +++-------------------
 src/photos-edit-palette.c          |   28 ++--------------------------
 src/photos-utils.c                 |   23 ++++++++++++++++++++++-
 src/photos-utils.h                 |    6 +++++-
 4 files changed, 32 insertions(+), 47 deletions(-)
---
diff --git a/src/photos-dlna-renderers-dialog.c b/src/photos-dlna-renderers-dialog.c
index 054493b..7f46cf3 100644
--- a/src/photos-dlna-renderers-dialog.c
+++ b/src/photos-dlna-renderers-dialog.c
@@ -1,7 +1,7 @@
 /*
  * Photos - access, organize and share your photos on GNOME
  * Copyright © 2013 Intel Corporation. All rights reserved.
- * Copyright © 2013, 2014, 2015 Red Hat, Inc.
+ * Copyright © 2013, 2014, 2015, 2016 Red Hat, Inc.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -37,6 +37,7 @@
 #include "photos-local-item.h"
 #include "photos-remote-display-manager.h"
 #include "photos-search-context.h"
+#include "photos-utils.h"
 
 
 struct _PhotosDlnaRenderersDialogPrivate
@@ -61,23 +62,6 @@ G_DEFINE_TYPE_WITH_PRIVATE (PhotosDlnaRenderersDialog, photos_dlna_renderers_dia
 
 
 static void
-photos_dlna_renderers_separator_cb (GtkListBoxRow *row,
-                                    GtkListBoxRow *before,
-                                    gpointer user_data)
-{
-  GtkWidget *separator;
-
-  separator = gtk_list_box_row_get_header (row);
-  if (separator == NULL && before != NULL)
-    {
-      separator = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
-      gtk_list_box_row_set_header (row, separator);
-      gtk_widget_show (separator);
-    }
-}
-
-
-static void
 photos_dlna_renderers_dialog_row_activated_cb (PhotosDlnaRenderersDialog *self,
                                                GtkListBoxRow             *row,
                                                gpointer                   user_data)
@@ -237,7 +221,7 @@ photos_dlna_renderers_dialog_init (PhotosDlnaRenderersDialog *self)
 
   gtk_widget_init_template (GTK_WIDGET (self));
 
-  gtk_list_box_set_header_func (priv->listbox, photos_dlna_renderers_separator_cb, NULL, NULL);
+  gtk_list_box_set_header_func (priv->listbox, photos_utils_list_box_header_func, NULL, NULL);
 
   renderers = photos_dlna_renderers_manager_dup_renderers (priv->renderers_mngr);
 
diff --git a/src/photos-edit-palette.c b/src/photos-edit-palette.c
index e5a5bc6..7beaedb 100644
--- a/src/photos-edit-palette.c
+++ b/src/photos-edit-palette.c
@@ -1,6 +1,6 @@
 /*
  * Photos - access, organize and share your photos on GNOME
- * Copyright © 2015 Red Hat, Inc.
+ * Copyright © 2015, 2016 Red Hat, Inc.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -101,27 +101,6 @@ photos_edit_palette_row_activated (GtkListBox *box, GtkListBoxRow *row)
 
 
 static void
-photos_edit_palette_update_header_func (GtkListBoxRow *row, GtkListBoxRow *before)
-{
-  GtkWidget *header;
-
-  if (before == NULL)
-    {
-      gtk_list_box_row_set_header (row, NULL);
-      return;
-    }
-
-  header = gtk_list_box_row_get_header (row);
-  if (header == NULL)
-    {
-      header = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
-      gtk_widget_show (header);
-      gtk_list_box_row_set_header (row, header);
-    }
-}
-
-
-static void
 photos_edit_palette_dispose (GObject *object)
 {
   PhotosEditPalette *self = PHOTOS_EDIT_PALETTE (object);
@@ -138,10 +117,7 @@ photos_edit_palette_init (PhotosEditPalette *self)
 {
   gtk_widget_set_vexpand (GTK_WIDGET (self), TRUE);
   gtk_list_box_set_selection_mode (GTK_LIST_BOX (self), GTK_SELECTION_NONE);
-  gtk_list_box_set_header_func (GTK_LIST_BOX (self),
-                                (GtkListBoxUpdateHeaderFunc) photos_edit_palette_update_header_func,
-                                NULL,
-                                NULL);
+  gtk_list_box_set_header_func (GTK_LIST_BOX (self), photos_utils_list_box_header_func, NULL, NULL);
 
   self->extension_point = g_io_extension_point_lookup (PHOTOS_TOOL_EXTENSION_POINT_NAME);
 
diff --git a/src/photos-utils.c b/src/photos-utils.c
index 7d46d4d..c5c64fd 100644
--- a/src/photos-utils.c
+++ b/src/photos-utils.c
@@ -1,6 +1,6 @@
 /*
  * Photos - access, organize and share your photos on GNOME
- * Copyright © 2012, 2013, 2014, 2015 Red Hat, Inc.
+ * Copyright © 2012, 2013, 2014, 2015, 2016 Red Hat, Inc.
  * Copyright © 2009 Yorba Foundation
  *
  * This program is free software; you can redistribute it and/or
@@ -1136,6 +1136,27 @@ photos_utils_icon_from_rdf_type (const gchar *type)
 }
 
 
+void
+photos_utils_list_box_header_func (GtkListBoxRow *row, GtkListBoxRow *before, gpointer user_data)
+{
+  GtkWidget *header;
+
+  if (before == NULL)
+    {
+      gtk_list_box_row_set_header (row, NULL);
+      return;
+    }
+
+  header = gtk_list_box_row_get_header (row);
+  if (header == NULL)
+    {
+      header = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
+      gtk_widget_show (header);
+      gtk_list_box_row_set_header (row, header);
+    }
+}
+
+
 gboolean
 photos_utils_make_directory_with_parents (GFile *file, GCancellable *cancellable, GError **error)
 {
diff --git a/src/photos-utils.h b/src/photos-utils.h
index cc63745..ecea156 100644
--- a/src/photos-utils.h
+++ b/src/photos-utils.h
@@ -1,6 +1,6 @@
 /*
  * Photos - access, organize and share your photos on GNOME
- * Copyright © 2012, 2013, 2014, 2015 Red Hat, Inc.
+ * Copyright © 2012, 2013, 2014, 2015, 2016 Red Hat, Inc.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -141,6 +141,10 @@ GList           *photos_utils_get_urns_from_paths         (GList *paths, GtkTree
 
 GIcon           *photos_utils_icon_from_rdf_type          (const gchar *type);
 
+void             photos_utils_list_box_header_func        (GtkListBoxRow *row,
+                                                           GtkListBoxRow *before,
+                                                           gpointer user_data);
+
 gboolean         photos_utils_make_directory_with_parents (GFile *file, GCancellable *cancellable, GError 
**error);
 
 GQuark           photos_utils_orientation_bottom_quark    (void);


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