changeset 32460:4cae9a5630e9

Re-arrange things a bit.
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Thu, 05 Jan 2012 08:14:09 +0000
parents 64aea8af2831
children 53d0779a32a1
files pidgin/gtkwebviewtoolbar.c
diffstat 1 files changed, 93 insertions(+), 79 deletions(-) [+]
line wrap: on
line diff
--- a/pidgin/gtkwebviewtoolbar.c	Thu Jan 05 08:04:26 2012 +0000
+++ b/pidgin/gtkwebviewtoolbar.c	Thu Jan 05 08:14:09 2012 +0000
@@ -43,8 +43,16 @@
 
 #include <gdk/gdkkeysyms.h>
 
+/******************************************************************************
+ * Globals
+ *****************************************************************************/
+
 static GtkHBoxClass *parent_class = NULL;
 
+/******************************************************************************
+ * Prototypes
+ *****************************************************************************/
+
 static void
 toggle_button_set_active_block(GtkToggleButton *button, gboolean is_active,
                                GtkWebViewToolbar *toolbar);
@@ -53,6 +61,10 @@
 gtk_webviewtoolbar_popup_menu(GtkWidget *widget, GdkEventButton *event,
                               GtkWebViewToolbar *toolbar);
 
+/******************************************************************************
+ * Helpers
+ *****************************************************************************/
+
 static void
 do_bold(GtkWidget *bold, GtkWebViewToolbar *toolbar)
 {
@@ -1147,10 +1159,83 @@
 	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), FALSE);
 }
 
-enum {
-	LAST_SIGNAL
-};
-/* static guint signals [LAST_SIGNAL] = { 0 }; */
+static void
+switch_toolbar_view(GtkWidget *item, GtkWebViewToolbar *toolbar)
+{
+	purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/conversations/toolbar/wide",
+			!purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/toolbar/wide"));
+}
+
+static gboolean
+gtk_webviewtoolbar_popup_menu(GtkWidget *widget, GdkEventButton *event,
+                              GtkWebViewToolbar *toolbar)
+{
+	GtkWidget *menu;
+	GtkWidget *item;
+	gboolean wide;
+
+	if (event->button != 3)
+		return FALSE;
+
+	wide = GTK_WIDGET_VISIBLE(toolbar->bold);
+
+	menu = gtk_menu_new();
+	item = gtk_menu_item_new_with_mnemonic(wide ? _("Group Items") : _("Ungroup Items"));
+	g_signal_connect(G_OBJECT(item), "activate", G_CALLBACK(switch_toolbar_view), toolbar);
+	gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
+	gtk_widget_show(item);
+
+	gtk_menu_popup(GTK_MENU(menu), NULL, NULL, pidgin_menu_position_func_helper,
+				widget, event->button, event->time);
+	return TRUE;
+}
+
+static void
+button_visibility_changed(GtkWidget *button, gpointer dontcare, GtkWidget *item)
+{
+	if (GTK_WIDGET_VISIBLE(button))
+		gtk_widget_hide(item);
+	else
+		gtk_widget_show(item);
+}
+
+static void
+button_sensitiveness_changed(GtkWidget *button, gpointer dontcare, GtkWidget *item)
+{
+	gtk_widget_set_sensitive(item, GTK_WIDGET_IS_SENSITIVE(button));
+}
+
+static void
+update_menuitem(GtkToggleButton *button, GtkCheckMenuItem *item)
+{
+	g_signal_handlers_block_by_func(G_OBJECT(item), G_CALLBACK(gtk_button_clicked), button);
+	gtk_check_menu_item_set_active(item, gtk_toggle_button_get_active(button));
+	g_signal_handlers_unblock_by_func(G_OBJECT(item), G_CALLBACK(gtk_button_clicked), button);
+}
+
+static void
+enable_markup(GtkWidget *widget, gpointer null)
+{
+	if (GTK_IS_LABEL(widget))
+		g_object_set(G_OBJECT(widget), "use-markup", TRUE, NULL);
+}
+
+static void
+webviewtoolbar_view_pref_changed(const char *name, PurplePrefType type,
+                                 gconstpointer value, gpointer toolbar)
+{
+	if (value) {
+		gtk_widget_hide_all(g_object_get_data(G_OBJECT(toolbar), "lean-view"));
+		gtk_widget_show_all(g_object_get_data(G_OBJECT(toolbar), "wide-view"));
+	} else {
+		gtk_widget_hide_all(g_object_get_data(G_OBJECT(toolbar), "wide-view"));
+		gtk_widget_show_all(g_object_get_data(G_OBJECT(toolbar), "lean-view"));
+	}
+}
+
+/******************************************************************************
+ * GObject stuff
+ *****************************************************************************/
 
 static void
 gtk_webviewtoolbar_finalize(GObject *object)
@@ -1201,38 +1286,6 @@
 }
 
 static void
-switch_toolbar_view(GtkWidget *item, GtkWebViewToolbar *toolbar)
-{
-	purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/conversations/toolbar/wide",
-			!purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/toolbar/wide"));
-}
-
-static gboolean
-gtk_webviewtoolbar_popup_menu(GtkWidget *widget, GdkEventButton *event,
-                              GtkWebViewToolbar *toolbar)
-{
-	GtkWidget *menu;
-	GtkWidget *item;
-	gboolean wide;
-
-	if (event->button != 3)
-		return FALSE;
-
-	wide = GTK_WIDGET_VISIBLE(toolbar->bold);
-
-	menu = gtk_menu_new();
-	item = gtk_menu_item_new_with_mnemonic(wide ? _("Group Items") : _("Ungroup Items"));
-	g_signal_connect(G_OBJECT(item), "activate", G_CALLBACK(switch_toolbar_view), toolbar);
-	gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
-	gtk_widget_show(item);
-
-	gtk_menu_popup(GTK_MENU(menu), NULL, NULL, pidgin_menu_position_func_helper,
-				widget, event->button, event->time);
-	return TRUE;
-}
-
-/* Boring GTK+ stuff */
-static void
 gtk_webviewtoolbar_class_init(GtkWebViewToolbarClass *class)
 {
 	GObjectClass *gobject_class;
@@ -1298,49 +1351,6 @@
 }
 
 static void
-button_visibility_changed(GtkWidget *button, gpointer dontcare, GtkWidget *item)
-{
-	if (GTK_WIDGET_VISIBLE(button))
-		gtk_widget_hide(item);
-	else
-		gtk_widget_show(item);
-}
-
-static void
-button_sensitiveness_changed(GtkWidget *button, gpointer dontcare, GtkWidget *item)
-{
-	gtk_widget_set_sensitive(item, GTK_WIDGET_IS_SENSITIVE(button));
-}
-
-static void
-update_menuitem(GtkToggleButton *button, GtkCheckMenuItem *item)
-{
-	g_signal_handlers_block_by_func(G_OBJECT(item), G_CALLBACK(gtk_button_clicked), button);
-	gtk_check_menu_item_set_active(item, gtk_toggle_button_get_active(button));
-	g_signal_handlers_unblock_by_func(G_OBJECT(item), G_CALLBACK(gtk_button_clicked), button);
-}
-
-static void
-enable_markup(GtkWidget *widget, gpointer null)
-{
-	if (GTK_IS_LABEL(widget))
-		g_object_set(G_OBJECT(widget), "use-markup", TRUE, NULL);
-}
-
-static void
-webviewtoolbar_view_pref_changed(const char *name, PurplePrefType type,
-                                 gconstpointer value, gpointer toolbar)
-{
-	if (value) {
-		gtk_widget_hide_all(g_object_get_data(G_OBJECT(toolbar), "lean-view"));
-		gtk_widget_show_all(g_object_get_data(G_OBJECT(toolbar), "wide-view"));
-	} else {
-		gtk_widget_hide_all(g_object_get_data(G_OBJECT(toolbar), "wide-view"));
-		gtk_widget_show_all(g_object_get_data(G_OBJECT(toolbar), "lean-view"));
-	}
-}
-
-static void
 gtk_webviewtoolbar_init(GtkWebViewToolbar *toolbar)
 {
 	GtkWidget *hbox = GTK_WIDGET(toolbar), *event = gtk_event_box_new();
@@ -1545,6 +1555,10 @@
 	gtk_widget_show(event);
 }
 
+/******************************************************************************
+ * Public API
+ *****************************************************************************/
+
 GtkWidget *
 gtk_webviewtoolbar_new(void)
 {