[gnome-control-center] shell: Make list box max height configurable
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] shell: Make list box max height configurable
- Date: Thu, 26 Jun 2014 14:02:12 +0000 (UTC)
commit f528de73aa6ccdcb5a7595b087e84eeeffa11ba9
Author: Bastien Nocera <hadess hadess net>
Date: Thu Jun 26 15:58:04 2014 +0200
shell: Make list box max height configurable
So that the Media sharing dialogue in the Sharing panel isn't too high.
shell/list-box-helper.c | 15 +++++++++++----
shell/list-box-helper.h | 3 ++-
2 files changed, 13 insertions(+), 5 deletions(-)
---
diff --git a/shell/list-box-helper.c b/shell/list-box-helper.c
index 3c68a1d..acd3a19 100644
--- a/shell/list-box-helper.c
+++ b/shell/list-box-helper.c
@@ -44,7 +44,7 @@ cc_list_box_adjust_scrolling (GtkListBox *listbox)
{
GtkWidget *scrolled_window;
GList *children;
- guint n_rows;
+ guint n_rows, num_max_rows;
scrolled_window = g_object_get_data (G_OBJECT (listbox), "cc-scrolling-scrolled-window");
if (!scrolled_window)
@@ -53,13 +53,15 @@ cc_list_box_adjust_scrolling (GtkListBox *listbox)
children = gtk_container_get_children (GTK_CONTAINER (listbox));
n_rows = g_list_length (children);
- if (n_rows >= MAX_ROWS_VISIBLE)
+ num_max_rows = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (listbox), "cc-max-rows-visible"));
+
+ if (n_rows >= num_max_rows)
{
gint total_row_height = 0;
GList *l;
guint i;
- for (l = children, i = 0; l != NULL && i < MAX_ROWS_VISIBLE; l = l->next, i++) {
+ for (l = children, i = 0; l != NULL && i < num_max_rows; l = l->next, i++) {
gint row_height;
gtk_widget_get_preferred_height (GTK_WIDGET (l->data), &row_height, NULL);
total_row_height += row_height;
@@ -80,7 +82,8 @@ cc_list_box_adjust_scrolling (GtkListBox *listbox)
}
void
-cc_list_box_setup_scrolling (GtkListBox *listbox)
+cc_list_box_setup_scrolling (GtkListBox *listbox,
+ guint num_max_rows)
{
GtkWidget *parent;
GtkWidget *scrolled_window;
@@ -96,5 +99,9 @@ cc_list_box_setup_scrolling (GtkListBox *listbox)
gtk_container_add (GTK_CONTAINER (parent), scrolled_window);
+ if (num_max_rows == 0)
+ num_max_rows = MAX_ROWS_VISIBLE;
+
g_object_set_data (G_OBJECT (listbox), "cc-scrolling-scrolled-window", scrolled_window);
+ g_object_set_data (G_OBJECT (listbox), "cc-max-rows-visible", GUINT_TO_POINTER (num_max_rows));
}
diff --git a/shell/list-box-helper.h b/shell/list-box-helper.h
index 0aad95d..8b480b8 100644
--- a/shell/list-box-helper.h
+++ b/shell/list-box-helper.h
@@ -27,4 +27,5 @@ void
cc_list_box_adjust_scrolling (GtkListBox *listbox);
void
-cc_list_box_setup_scrolling (GtkListBox *listbox);
+cc_list_box_setup_scrolling (GtkListBox *listbox,
+ guint num_rows);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]