Commit c71402af authored by Debarshi Ray's avatar Debarshi Ray

Add a helper to set GtkListBox separators and use it everywhere

parent aeaf5869
/*
* 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
......@@ -60,23 +61,6 @@ enum
G_DEFINE_TYPE_WITH_PRIVATE (PhotosDlnaRenderersDialog, photos_dlna_renderers_dialog, GTK_TYPE_DIALOG);
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,
......@@ -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);
......
/*
* 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
......@@ -100,27 +100,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)
{
......@@ -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);
......
/*
* 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)
{
......
/*
* 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);
......
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