sharing: Convert to GtkListBox

https://bugzilla.gnome.org/show_bug.cgi?id=702164
This commit is contained in:
Alexander Larsson 2013-06-13 12:21:30 +02:00 committed by Thomas Wood
parent a46a652093
commit c0abad92e1
2 changed files with 55 additions and 31 deletions

View file

@ -20,7 +20,6 @@
*/ */
#include "cc-sharing-panel.h" #include "cc-sharing-panel.h"
#include "egg-list-box/egg-list-box.h"
#include "shell/cc-hostname-entry.h" #include "shell/cc-hostname-entry.h"
#include "cc-sharing-resources.h" #include "cc-sharing-resources.h"
@ -209,18 +208,18 @@ cc_sharing_panel_run_dialog (CcSharingPanel *self,
} }
static void static void
cc_sharing_panel_main_list_box_child_activated (EggListBox *listbox, cc_sharing_panel_main_list_box_row_activated (GtkListBox *listbox,
GtkWidget *widget, GtkListBoxRow *row,
CcSharingPanel *self) CcSharingPanel *self)
{ {
gchar *widget_name, *found; gchar *widget_name, *found;
widget_name = g_strdup (gtk_buildable_get_name (GTK_BUILDABLE (widget))); widget_name = g_strdup (gtk_buildable_get_name (GTK_BUILDABLE (row)));
if (!widget_name) if (!widget_name)
return; return;
egg_list_box_select_child (listbox, NULL); gtk_list_box_select_row (listbox, NULL);
/* replace "button" with "dialog" */ /* replace "button" with "dialog" */
found = g_strrstr (widget_name, "button"); found = g_strrstr (widget_name, "button");
@ -237,22 +236,22 @@ out:
} }
static void static void
cc_sharing_panel_main_list_box_update_separator (GtkWidget **separator, cc_sharing_panel_main_list_box_update_header (GtkListBoxRow *row,
GtkWidget *child, GtkListBoxRow *before,
GtkWidget *before,
gpointer user_data) gpointer user_data)
{ {
GtkWidget *current;
if (before == NULL) if (before == NULL)
return;
current = gtk_list_box_row_get_header (row);
if (current == NULL)
{ {
g_clear_object (separator); current = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
return; gtk_widget_show (current);
gtk_list_box_row_set_header (row, current);
} }
if (*separator != NULL)
return;
*separator = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
g_object_ref_sink (*separator);
} }
static gboolean static gboolean
@ -984,8 +983,8 @@ cc_sharing_panel_init (CcSharingPanel *self)
gtk_container_add (GTK_CONTAINER (self), WID ("sharing-panel")); gtk_container_add (GTK_CONTAINER (self), WID ("sharing-panel"));
g_signal_connect (WID ("main-list-box"), "child-activated", g_signal_connect (WID ("main-list-box"), "row-activated",
G_CALLBACK (cc_sharing_panel_main_list_box_child_activated), self); G_CALLBACK (cc_sharing_panel_main_list_box_row_activated), self);
priv->hostname_cancellable = g_cancellable_new (); priv->hostname_cancellable = g_cancellable_new ();
@ -1007,10 +1006,10 @@ cc_sharing_panel_init (CcSharingPanel *self)
g_signal_connect (priv->screen_sharing_dialog, "response", g_signal_connect (priv->screen_sharing_dialog, "response",
G_CALLBACK (gtk_widget_hide), NULL); G_CALLBACK (gtk_widget_hide), NULL);
egg_list_box_set_activate_on_single_click (EGG_LIST_BOX (WID ("main-list-box")), gtk_list_box_set_activate_on_single_click (GTK_LIST_BOX (WID ("main-list-box")),
TRUE); TRUE);
egg_list_box_set_separator_funcs (EGG_LIST_BOX (WID ("main-list-box")), gtk_list_box_set_header_func (GTK_LIST_BOX (WID ("main-list-box")),
cc_sharing_panel_main_list_box_update_separator, cc_sharing_panel_main_list_box_update_header,
NULL, NULL); NULL, NULL);
/* create the master switch */ /* create the master switch */

View file

@ -264,10 +264,13 @@
<property name="label_xalign">0</property> <property name="label_xalign">0</property>
<property name="shadow_type">in</property> <property name="shadow_type">in</property>
<child> <child>
<object class="EggListBox" id="main-list-box"> <object class="GtkListBox" id="main-list-box">
<property name="visible">True</property> <property name="visible">True</property>
<child> <child>
<object class="GtkBox" id="bluetooth-sharing-button"> <object class="GtkListBoxRow" id="bluetooth-sharing-button">
<property name="visible">True</property>
<child>
<object class="GtkBox" id="box1">
<property name="border-width">12</property> <property name="border-width">12</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
@ -299,8 +302,13 @@
</child> </child>
</object> </object>
</child> </child>
</object>
</child>
<child> <child>
<object class="GtkBox" id="personal-file-sharing-button"> <object class="GtkListBoxRow" id="personal-file-sharing-button">
<property name="visible">True</property>
<child>
<object class="GtkBox" id="box2">
<property name="border-width">12</property> <property name="border-width">12</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
@ -332,8 +340,13 @@
</child> </child>
</object> </object>
</child> </child>
</object>
</child>
<child> <child>
<object class="GtkBox" id="screen-sharing-button"> <object class="GtkListBoxRow" id="screen-sharing-button">
<property name="visible">True</property>
<child>
<object class="GtkBox" id="box3">
<property name="border-width">12</property> <property name="border-width">12</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
@ -365,8 +378,13 @@
</child> </child>
</object> </object>
</child> </child>
</object>
</child>
<child> <child>
<object class="GtkBox" id="media-sharing-button"> <object class="GtkListBoxRow" id="media-sharing-button">
<property name="visible">True</property>
<child>
<object class="GtkBox" id="box4">
<property name="border-width">12</property> <property name="border-width">12</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
@ -398,8 +416,13 @@
</child> </child>
</object> </object>
</child> </child>
</object>
</child>
<child> <child>
<object class="GtkBox" id="remote-login-button"> <object class="GtkListBoxRow" id="remote-login-button">
<property name="visible">True</property>
<child>
<object class="GtkBox" id="box5">
<property name="border-width">12</property> <property name="border-width">12</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
@ -435,6 +458,8 @@
</object> </object>
</child> </child>
</object> </object>
</child>
</object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
@ -1081,7 +1106,7 @@
<property name="orientation">vertical</property> <property name="orientation">vertical</property>
<property name="spacing">12</property> <property name="spacing">12</property>
<child> <child>
<object class="GtkBox" id="box1"> <object class="GtkBox" id="box6">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<child> <child>