]> spindle.queued.net Git - midori/commitdiff
Move variable declarations to the beginnings of blocks
authorChristian Dywan <christian@twotoasts.de>
Sun, 16 Nov 2008 01:00:17 +0000 (02:00 +0100)
committerChristian Dywan <christian@twotoasts.de>
Sun, 16 Nov 2008 01:00:17 +0000 (02:00 +0100)
midori/midori-browser.c
midori/midori-console.c
midori/midori-panel.c
midori/midori-preferences.c
midori/midori-view.c
midori/midori-websettings.c
midori/sokoke.c

index ce8b3049341929f2c25b39c97dce13f26e57983e..6d843ed5fa60eeea7ac5aa06abbf81385a9951b7 100644 (file)
@@ -1281,8 +1281,10 @@ _action_open_activate (GtkAction*     action,
 
      if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
      {
+         gchar* folder;
+
+         folder = gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (dialog));
          uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (dialog));
-         gchar* folder = gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (dialog));
          midori_browser_set_current_uri (browser, uri);
 
          g_free (last_dir);
index 2a4df53974d09dc7da7369998c3bb77911d67bcb..507b26dcb01b0dfdfcf36796a11d3515d818de7b 100644 (file)
@@ -64,9 +64,11 @@ midori_console_treeview_render_text_cb (GtkTreeViewColumn* column,
     gchar* message;
     gint   line;
     gchar* source_id;
+    gchar* text;
+
     gtk_tree_model_get (model, iter, 0, &message, 1, &line, 2, &source_id, -1);
 
-    gchar* text = g_strdup_printf ("%d @ %s\n%s", line, source_id, message);
+    text = g_strdup_printf ("%d @ %s\n%s", line, source_id, message);
     g_object_set (renderer, "text", text, NULL);
     g_free (text);
 
@@ -153,10 +155,13 @@ midori_console_get_toolbar (MidoriConsole* console)
 
     if (!console->toolbar)
     {
-        GtkWidget* toolbar = gtk_toolbar_new ();
+        GtkWidget* toolbar;
+        GtkToolItem* toolitem;
+
+        toolbar = gtk_toolbar_new ();
         gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_BOTH_HORIZ);
         gtk_toolbar_set_icon_size (GTK_TOOLBAR (toolbar), GTK_ICON_SIZE_BUTTON);
-        GtkToolItem* toolitem = gtk_tool_item_new ();
+        toolitem = gtk_tool_item_new ();
         /* TODO: What about a find entry here that filters e.g. by url? */
         gtk_toolbar_insert (GTK_TOOLBAR (toolbar), toolitem, -1);
         gtk_widget_show (GTK_WIDGET (toolitem));
index c4fd41be983a432fc29e0dc11ba7f64a253d372d..2a2cb6f4bbc95f00f01ca3ca68cfc0b804f83979 100644 (file)
@@ -109,6 +109,9 @@ midori_cclosure_marshal_BOOLEAN__VOID (GClosure*     closure,
 static void
 midori_panel_class_init (MidoriPanelClass* class)
 {
+    GObjectClass* gobject_class;
+    GParamFlags flags;
+
 
     signals[CLOSE] = g_signal_new (
         "close",
@@ -133,12 +136,12 @@ midori_panel_class_init (MidoriPanelClass* class)
 
     class->close = midori_panel_close_cb;
 
-    GObjectClass* gobject_class = G_OBJECT_CLASS (class);
+    gobject_class = G_OBJECT_CLASS (class);
     gobject_class->finalize = midori_panel_finalize;
     gobject_class->set_property = midori_panel_set_property;
     gobject_class->get_property = midori_panel_get_property;
 
-    GParamFlags flags = G_PARAM_READWRITE | G_PARAM_CONSTRUCT;
+    flags = G_PARAM_READWRITE | G_PARAM_CONSTRUCT;
 
     g_object_class_install_property (gobject_class,
                                      PROP_SHADOW_TYPE,
@@ -180,6 +183,10 @@ midori_panel_button_close_clicked_cb (GtkWidget*   toolitem,
 static void
 midori_panel_init (MidoriPanel* panel)
 {
+    GtkWidget* vbox;
+    GtkWidget* labelbar;
+    GtkToolItem* toolitem;
+
     /* Create the sidebar */
     panel->toolbar = gtk_toolbar_new ();
     gtk_toolbar_set_style (GTK_TOOLBAR (panel->toolbar), GTK_TOOLBAR_BOTH);
@@ -189,14 +196,14 @@ midori_panel_init (MidoriPanel* panel)
                                  GTK_ORIENTATION_VERTICAL);
     gtk_box_pack_start (GTK_BOX (panel), panel->toolbar, FALSE, FALSE, 0);
     gtk_widget_show_all (panel->toolbar);
-    GtkWidget* vbox = gtk_vbox_new (FALSE, 0);
+    vbox = gtk_vbox_new (FALSE, 0);
     gtk_box_pack_start (GTK_BOX (panel), vbox, TRUE, TRUE, 0);
 
     /* Create the titlebar */
-    GtkWidget* labelbar = gtk_toolbar_new ();
+    labelbar = gtk_toolbar_new ();
     gtk_toolbar_set_icon_size (GTK_TOOLBAR (labelbar), GTK_ICON_SIZE_MENU);
     gtk_toolbar_set_style (GTK_TOOLBAR (labelbar), GTK_TOOLBAR_ICONS);
-    GtkToolItem* toolitem = gtk_tool_item_new ();
+    toolitem = gtk_tool_item_new ();
     gtk_tool_item_set_expand (toolitem, TRUE);
     panel->toolbar_label = gtk_label_new (NULL);
     gtk_misc_set_alignment (GTK_MISC (panel->toolbar_label), 0, 0.5);
@@ -559,9 +566,12 @@ gint
 midori_panel_page_num (MidoriPanel* panel,
                        GtkWidget*   child)
 {
+    GtkWidget* scrolled;
+
     g_return_val_if_fail (MIDORI_IS_PANEL (panel), -1);
+    g_return_val_if_fail (GTK_IS_WIDGET (child), -1);
 
-    GtkWidget* scrolled = _midori_panel_scrolled_for_child (panel, child);
+    scrolled = _midori_panel_scrolled_for_child (panel, child);
     return gtk_notebook_page_num (GTK_NOTEBOOK (panel->notebook), scrolled);
 }
 
@@ -579,12 +589,14 @@ void
 midori_panel_set_current_page (MidoriPanel* panel,
                                gint         n)
 {
+    GtkWidget* child;
+
     g_return_if_fail (MIDORI_IS_PANEL (panel));
 
     gtk_notebook_set_current_page (GTK_NOTEBOOK (panel->toolbook), n);
     gtk_notebook_set_current_page (GTK_NOTEBOOK (panel->notebook), n);
-    GtkWidget* child = midori_panel_get_nth_page (panel, n);
-    if (child)
+
+    if ((child = midori_panel_get_nth_page (panel, n)))
     {
         const gchar* label = g_object_get_data (G_OBJECT (child), "label");
         g_object_set (panel->toolbar_label, "label", label, NULL);
index ec519aae0b04518f1bea5698a6d99483e9dcf9e7..58791794d2a57ca1cfd9f0aec31ff7eec020c502 100644 (file)
@@ -167,13 +167,15 @@ GtkWidget*
 midori_preferences_new (GtkWindow*         parent,
                         MidoriWebSettings* settings)
 {
+    MidoriPreferences* preferences;
+
     g_return_val_if_fail (GTK_IS_WINDOW (parent), NULL);
     g_return_val_if_fail (MIDORI_IS_WEB_SETTINGS (settings), NULL);
 
-    MidoriPreferences* preferences = g_object_new (MIDORI_TYPE_PREFERENCES,
-                                                   "transient-for", parent,
-                                                   "settings", settings,
-                                                   NULL);
+    preferences = g_object_new (MIDORI_TYPE_PREFERENCES,
+                                "transient-for", parent,
+                                "settings", settings,
+                                NULL);
 
     return GTK_WIDGET (preferences);
 }
index 65ba2ecad3ff0b5dfa3611613dcb3c926de2401d..36c90dfebec2e7eb994dcabe58cf509e4e4e8357 100644 (file)
@@ -76,14 +76,16 @@ GType
 midori_load_status_get_type (void)
 {
     static GType type = 0;
-    if (type)
-        return type;
     static const GEnumValue values[] = {
      { MIDORI_LOAD_PROVISIONAL, "MIDORI_LOAD_PROVISIONAL", "Load Provisional" },
      { MIDORI_LOAD_COMMITTED, "MIDORI_LOAD_COMMITTED", "Load Committed" },
      { MIDORI_LOAD_FINISHED, "MIDORI_LOAD_FINISHED", "Load Finished" },
      { 0, NULL, NULL }
     };
+
+    if (type)
+        return type;
+
     type = g_enum_register_static ("MidoriLoadStatus", values);
     return type;
 }
index fc6b1ba0a4f9a184fec3acbc15950726c8bb22e5..e548710483603a95d4f891a39d911223d024fec8 100644 (file)
@@ -230,12 +230,15 @@ midori_web_settings_get_property (GObject*    object,
 static void
 midori_web_settings_class_init (MidoriWebSettingsClass* class)
 {
-    GObjectClass* gobject_class = G_OBJECT_CLASS (class);
+    GObjectClass* gobject_class;
+    GParamFlags flags;
+
+    gobject_class = G_OBJECT_CLASS (class);
     gobject_class->finalize = midori_web_settings_finalize;
     gobject_class->set_property = midori_web_settings_set_property;
     gobject_class->get_property = midori_web_settings_get_property;
 
-    GParamFlags flags = G_PARAM_READWRITE | G_PARAM_CONSTRUCT;
+    flags = G_PARAM_READWRITE | G_PARAM_CONSTRUCT;
 
     g_object_class_install_property (gobject_class,
                                      PROP_REMEMBER_LAST_WINDOW_SIZE,
@@ -610,11 +613,14 @@ static void
 notify_default_encoding_cb (GObject*    object,
                             GParamSpec* pspec)
 {
-    MidoriWebSettings* web_settings = MIDORI_WEB_SETTINGS (object);
-
+    MidoriWebSettings* web_settings;
     const gchar* string;
+    const gchar* encoding;
+
+    web_settings = MIDORI_WEB_SETTINGS (object);
+
     g_object_get (object, "default-encoding", &string, NULL);
-    const gchar* encoding = string ? string : "";
+    encoding = string ? string : "";
     if (!strcmp (encoding, "BIG5"))
         web_settings->preferred_encoding = MIDORI_ENCODING_CHINESE;
     else if (!strcmp (encoding, "SHIFT_JIS"))
index 776931c324043e2100eca5aabeea15529ed05427..d170e5b98394f5df8168febd94934551f65705ec 100644 (file)
@@ -178,12 +178,13 @@ void
 sokoke_combo_box_add_strings (GtkComboBox* combobox,
                               const gchar* label_first, ...)
 {
+    const gchar* label;
+
     /* Add a number of strings to a combobox, terminated with NULL
        This works only for text comboboxes */
     va_list args;
     va_start (args, label_first);
 
-    const gchar* label;
     for (label = label_first; label; label = va_arg (args, const gchar*))
         gtk_combo_box_append_text (combobox, label);
 
@@ -255,17 +256,22 @@ sokoke_xfce_header_new (const gchar* icon,
        This returns NULL if the desktop is not Xfce */
     if (sokoke_get_desktop () == SOKOKE_DESKTOP_XFCE)
     {
-        GtkWidget* entry = gtk_entry_new ();
+        GtkWidget* entry;
         gchar* markup;
-        GtkWidget* xfce_heading = gtk_event_box_new ();
+        GtkWidget* xfce_heading;
+        GtkWidget* hbox;
+        GtkWidget* image;
+        GtkWidget* label;
+
+        xfce_heading = gtk_event_box_new ();
+        entry = gtk_entry_new ();
         gtk_widget_modify_bg (xfce_heading, GTK_STATE_NORMAL,
             &entry->style->base[GTK_STATE_NORMAL]);
-        GtkWidget* hbox = gtk_hbox_new (FALSE, 12);
+        hbox = gtk_hbox_new (FALSE, 12);
         gtk_container_set_border_width (GTK_CONTAINER (hbox), 6);
-        GtkWidget* image = gtk_image_new_from_icon_name (icon,
-                                                         GTK_ICON_SIZE_DIALOG);
+        image = gtk_image_new_from_icon_name (icon, GTK_ICON_SIZE_DIALOG);
         gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
-        GtkWidget* label = gtk_label_new (NULL);
+        label = gtk_label_new (NULL);
         gtk_widget_modify_fg (label, GTK_STATE_NORMAL
          , &entry->style->text[GTK_STATE_NORMAL]);
         markup = g_strdup_printf ("<span size='large' weight='bold'>%s</span>",
@@ -287,11 +293,13 @@ sokoke_superuser_warning_new (void)
     #if HAVE_UNISTD_H
     if (G_UNLIKELY (!geteuid ())) /* effective superuser? */
     {
-        GtkWidget* hbox = gtk_event_box_new ();
+        GtkWidget* hbox;
+        GtkWidget* label;
+
+        hbox = gtk_event_box_new ();
         gtk_widget_modify_bg (hbox, GTK_STATE_NORMAL,
                               &hbox->style->bg[GTK_STATE_SELECTED]);
-        GtkWidget* label = gtk_label_new (
-            _("Warning: You are using a superuser account!"));
+        label = gtk_label_new (_("Warning: You are using a superuser account!"));
         gtk_misc_set_padding (GTK_MISC (label), 0, 2);
         gtk_widget_modify_fg (GTK_WIDGET (label), GTK_STATE_NORMAL,
             &GTK_WIDGET (label)->style->fg[GTK_STATE_SELECTED]);
@@ -458,10 +466,13 @@ sokoke_key_file_save_to_file (GKeyFile*    key_file,
                               const gchar* filename,
                               GError**     error)
 {
-    gchar* data = g_key_file_to_data (key_file, NULL, error);
+    gchar* data;
+    FILE* fp;
+
+    data = g_key_file_to_data (key_file, NULL, error);
     if (!data)
         return FALSE;
-    FILE* fp;
+
     if (!(fp = fopen (filename, "w")))
     {
         *error = g_error_new (G_FILE_ERROR, G_FILE_ERROR_ACCES,