[gnome-applets] window-buttons: fix -Wdeclaration-after-statement warnings



commit 757a3954c3c55d3806b9e5ade2f156dcc16fc603
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Fri Apr 3 21:34:29 2020 +0300

    window-buttons: fix -Wdeclaration-after-statement warnings

 gnome-applets/window-buttons/external.c       | 37 ++++++++++++-----
 gnome-applets/window-buttons/preferences.c    | 59 +++++++++++++++++----------
 gnome-applets/window-buttons/theme.c          | 33 ++++++++++-----
 gnome-applets/window-buttons/window-buttons.c | 11 +++--
 4 files changed, 94 insertions(+), 46 deletions(-)
---
diff --git a/gnome-applets/window-buttons/external.c b/gnome-applets/window-buttons/external.c
index 91006154e..554cc36f1 100755
--- a/gnome-applets/window-buttons/external.c
+++ b/gnome-applets/window-buttons/external.c
@@ -57,37 +57,52 @@ gchar *getMetacityLayout() {
        return retval;
 }
 
-gboolean issetCompizDecoration() {
+gboolean
+issetCompizDecoration ()
+{
+       gboolean retval;
+       GSettings *settings;
+       gchar *current_profile;
+       gchar *path;
+       gchar *cdm;
+
        if(!decorPluginInstalled()) return FALSE;
 
-       gboolean retval = FALSE;
-       
-       GSettings *settings = g_settings_new(GSETTINGS_COMPIZ_SCHEMA);
-       gchar *current_profile = g_settings_get_string(settings, CFG_COMPIZ_CURRENT_PROFILE);
+       retval = FALSE;
+
+       settings = g_settings_new(GSETTINGS_COMPIZ_SCHEMA);
+       current_profile = g_settings_get_string(settings, CFG_COMPIZ_CURRENT_PROFILE);
 
-       gchar *path = g_strdup_printf(GSETTINGS_COMPIZ_DECOR_PATH, current_profile);
+       path = g_strdup_printf(GSETTINGS_COMPIZ_DECOR_PATH, current_profile);
 
        settings = g_settings_new_with_path(GSETTINGS_COMPIZ_DECOR_SCHEMA, path);
-       gchar *cdm = g_settings_get_string(settings, CFG_COMPIZ_DECORATION_MATCH);
+       cdm = g_settings_get_string(settings, CFG_COMPIZ_DECORATION_MATCH);
 
        if (cdm == NULL) {
                retval = FALSE;
        } else if (!g_strcmp0(cdm, CFG_COMPIZ_DECORATION_MATCH_VALUE)) {
                retval = TRUE;
        }
+
        g_free(cdm);
        g_free(path);
        g_object_unref(settings);
        return retval;
 }
 
-void toggleCompizDecoration(gboolean new_value) {
+void
+toggleCompizDecoration(gboolean new_value)
+{
+       GSettings *settings;
+       gchar *current_profile;
+       gchar *path;
+
        if(!decorPluginInstalled()) return;
 
-       GSettings *settings = g_settings_new(GSETTINGS_COMPIZ_SCHEMA);
-       gchar *current_profile = g_settings_get_string(settings, CFG_COMPIZ_CURRENT_PROFILE);
+       settings = g_settings_new(GSETTINGS_COMPIZ_SCHEMA);
+       current_profile = g_settings_get_string(settings, CFG_COMPIZ_CURRENT_PROFILE);
 
-       gchar *path = g_strdup_printf(GSETTINGS_COMPIZ_DECOR_PATH, current_profile);
+       path = g_strdup_printf(GSETTINGS_COMPIZ_DECOR_PATH, current_profile);
 
        settings = g_settings_new_with_path(GSETTINGS_COMPIZ_DECOR_SCHEMA, path);
 
diff --git a/gnome-applets/window-buttons/preferences.c b/gnome-applets/window-buttons/preferences.c
index f040e02b0..551597055 100755
--- a/gnome-applets/window-buttons/preferences.c
+++ b/gnome-applets/window-buttons/preferences.c
@@ -138,14 +138,14 @@ loadPreferences (WBApplet *wbapplet)
 gshort *getEBPos(gchar *button_layout) {
        gshort *ebps = g_new(gshort, WB_BUTTONS);
        gint i, j;
+       gchar **pch;
 
        // in case we got a faulty button_layout:
        for (i=0; i<WB_BUTTONS; i++) ebps[i] = i;
                if (button_layout == NULL || *button_layout == '\0')
                        return ebps;
 
-//     for(i=0; i<WB_BUTTONS; i++) ebps[i] = -1; //set to -1 if we don't find some
-       gchar **pch = g_strsplit_set(button_layout, ":, ", -1);
+       pch = g_strsplit_set(button_layout, ":, ", -1);
        i = 0; j = 0;
        while (pch[j]) {
                if (!g_strcmp0(pch[j], "minimize")) ebps[0] = i++;
@@ -290,8 +290,10 @@ static void
 cb_show_tooltips (GtkButton *button,
                   WBApplet  *wbapplet)
 {
-       wbapplet->prefs->show_tooltips = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(button));
        gint i;
+
+       wbapplet->prefs->show_tooltips = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(button));
+
        for (i=0; i<WB_BUTTONS; i++)
                gtk_widget_set_has_tooltip (GTK_WIDGET(wbapplet->button[i]->image), 
wbapplet->prefs->show_tooltips);
        savePreferences(wbapplet->prefs, wbapplet);
@@ -325,9 +327,11 @@ cb_metacity_layout (GtkButton *button,
                wbapplet->prefs->button_layout = getMetacityLayout();
                gtk_widget_set_sensitive(GTK_WIDGET(entry_custom_layout), FALSE);
        } else {
+               gchar *new_layout;
+
                gtk_widget_set_sensitive(GTK_WIDGET(entry_custom_layout), TRUE);
                wbapplet->prefs->use_metacity_layout = FALSE;
-               gchar *new_layout = g_strdup(gtk_entry_get_text(entry_custom_layout));
+               new_layout = g_strdup(gtk_entry_get_text(entry_custom_layout));
                wbapplet->prefs->button_layout = new_layout;
        }
 
@@ -413,6 +417,21 @@ wb_applet_properties_cb (GSimpleAction *action,
        GtkWidget               ***btn;
        ImageOpenData   ***iod;
        gint i,j;
+       GtkToggleButton *chkb_only_maximized;
+       GtkToggleButton *chkb_click_effect;
+       GtkToggleButton *chkb_hover_effect;
+       GtkToggleButton *chkb_hide_on_unmaximized;
+       GtkToggleButton *chkb_reverse_order;
+       GtkToggleButton *chkb_hide_decoration;
+       GtkToggleButton *chkb_metacity_order;
+       GtkToggleButton *chkb_show_tooltips;
+       GtkButton *btn_reload_order;
+       GtkButton *btn_close;
+       GtkEntry *entry_custom_order;
+       GtkComboBox *combo_theme;
+       GtkToggleButton **chkb_btn_hidden;
+       GtkRadioButton **radio_orientation;
+       CheckBoxData **cbd;
 
        wbapplet = (WBApplet *) user_data;
 
@@ -442,22 +461,20 @@ wb_applet_properties_cb (GSimpleAction *action,
                }
        }
 
-       GtkToggleButton
-               *chkb_only_maximized = GTK_TOGGLE_BUTTON (gtk_builder_get_object(wbapplet->prefbuilder, 
CFG_ONLY_MAXIMIZED)),
-               *chkb_click_effect = GTK_TOGGLE_BUTTON (gtk_builder_get_object(wbapplet->prefbuilder, 
CFG_CLICK_EFFECT)),
-               *chkb_hover_effect = GTK_TOGGLE_BUTTON (gtk_builder_get_object(wbapplet->prefbuilder, 
CFG_HOVER_EFFECT)),
-               *chkb_hide_on_unmaximized = GTK_TOGGLE_BUTTON (gtk_builder_get_object(wbapplet->prefbuilder, 
CFG_HIDE_ON_UNMAXIMIZED)),
-               *chkb_reverse_order = GTK_TOGGLE_BUTTON (gtk_builder_get_object(wbapplet->prefbuilder, 
CFG_REVERSE_ORDER)),
-               *chkb_hide_decoration = GTK_TOGGLE_BUTTON (gtk_builder_get_object(wbapplet->prefbuilder, 
CFG_HIDE_DECORATION)),
-               *chkb_metacity_order = GTK_TOGGLE_BUTTON (gtk_builder_get_object(wbapplet->prefbuilder, 
CFG_USE_METACITY_LAYOUT)),
-               *chkb_show_tooltips = GTK_TOGGLE_BUTTON (gtk_builder_get_object(wbapplet->prefbuilder, 
CFG_SHOW_TOOLTIPS));
-       GtkButton
-               *btn_reload_order = GTK_BUTTON (gtk_builder_get_object(wbapplet->prefbuilder, 
"btn_reload_order")),
-               *btn_close = GTK_BUTTON (gtk_builder_get_object(wbapplet->prefbuilder, "btn_close"));
-       GtkEntry *entry_custom_order = GTK_ENTRY (gtk_builder_get_object(wbapplet->prefbuilder, 
CFG_BUTTON_LAYOUT));
-       GtkComboBox *combo_theme = GTK_COMBO_BOX (gtk_builder_get_object(wbapplet->prefbuilder, CFG_THEME));
-       GtkToggleButton **chkb_btn_hidden = getHideButtons(wbapplet->prefbuilder);
-       GtkRadioButton **radio_orientation = getOrientationButtons(wbapplet->prefbuilder);
+       chkb_only_maximized = GTK_TOGGLE_BUTTON (gtk_builder_get_object(wbapplet->prefbuilder, 
CFG_ONLY_MAXIMIZED));
+       chkb_click_effect = GTK_TOGGLE_BUTTON (gtk_builder_get_object(wbapplet->prefbuilder, 
CFG_CLICK_EFFECT));
+       chkb_hover_effect = GTK_TOGGLE_BUTTON (gtk_builder_get_object(wbapplet->prefbuilder, 
CFG_HOVER_EFFECT));
+       chkb_hide_on_unmaximized = GTK_TOGGLE_BUTTON (gtk_builder_get_object(wbapplet->prefbuilder, 
CFG_HIDE_ON_UNMAXIMIZED));
+       chkb_reverse_order = GTK_TOGGLE_BUTTON (gtk_builder_get_object(wbapplet->prefbuilder, 
CFG_REVERSE_ORDER));
+       chkb_hide_decoration = GTK_TOGGLE_BUTTON (gtk_builder_get_object(wbapplet->prefbuilder, 
CFG_HIDE_DECORATION));
+       chkb_metacity_order = GTK_TOGGLE_BUTTON (gtk_builder_get_object(wbapplet->prefbuilder, 
CFG_USE_METACITY_LAYOUT));
+       chkb_show_tooltips = GTK_TOGGLE_BUTTON (gtk_builder_get_object(wbapplet->prefbuilder, 
CFG_SHOW_TOOLTIPS));
+       btn_reload_order = GTK_BUTTON (gtk_builder_get_object(wbapplet->prefbuilder, "btn_reload_order"));
+       btn_close = GTK_BUTTON (gtk_builder_get_object(wbapplet->prefbuilder, "btn_close"));
+       entry_custom_order = GTK_ENTRY (gtk_builder_get_object(wbapplet->prefbuilder, CFG_BUTTON_LAYOUT));
+       combo_theme = GTK_COMBO_BOX (gtk_builder_get_object(wbapplet->prefbuilder, CFG_THEME));
+       chkb_btn_hidden = getHideButtons(wbapplet->prefbuilder);
+       radio_orientation = getOrientationButtons(wbapplet->prefbuilder);
 
        loadThemeComboBox(combo_theme, wbapplet->prefs->theme);
        loadThemeButtons(btn, wbapplet->pixbufs, wbapplet->prefs->images);
@@ -475,7 +492,7 @@ wb_applet_properties_cb (GSimpleAction *action,
        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(radio_orientation[wbapplet->prefs->orientation]), 
TRUE);
        gtk_entry_set_text (entry_custom_order, (const gchar*)wbapplet->prefs->button_layout);
 
-       CheckBoxData **cbd = g_new(CheckBoxData*, WB_BUTTONS);
+       cbd = g_new(CheckBoxData*, WB_BUTTONS);
        for (i=0; i<WB_BUTTONS; i++) {
                cbd[i] = g_new(CheckBoxData,1);
                cbd[i]->button_id = i;
diff --git a/gnome-applets/window-buttons/theme.c b/gnome-applets/window-buttons/theme.c
index 9c047c687..146125830 100755
--- a/gnome-applets/window-buttons/theme.c
+++ b/gnome-applets/window-buttons/theme.c
@@ -90,23 +90,34 @@ const gchar* getButtonImageState4(int state_id) { // old 4-state mode for backwa
        }
 }
 
-/* Load the themes into a combo Box */
-void loadThemeComboBox(GtkComboBox *combo, gchar *active_theme) {
-       GtkTreeIter             iter;
-       GtkListStore    *store = gtk_list_store_new( 3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INT );
-       // (0=real_name, 1=display_name, 2=id)
+void
+loadThemeComboBox (GtkComboBox *combo,
+                   gchar       *active_theme)
+{
+       GError *error;
+       GDir *dir_themes;
+       gint active;
+       gint N_THEMES;
+       GtkListStore *store;
+       const gchar *curtheme;
+       GtkTreeIter iter;
+       GtkCellRenderer *cell;
+
+       error = NULL;
+       dir_themes = g_dir_open(PATH_THEMES, 0, &error);
 
-       GError  *error = NULL;
-       GDir    *dir_themes = g_dir_open(PATH_THEMES, 0, &error);
        if (error) {
                g_printerr ("g_dir_open(%s) failed - %s\n", PATH_THEMES, error->message);
                g_error_free(error);
                return;
        }
 
-       gint active = -1;
-       gint N_THEMES = 0;
-       const gchar *curtheme;
+       active = -1;
+       N_THEMES = 0;
+
+       // (0=real_name, 1=display_name, 2=id)
+       store = gtk_list_store_new (3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INT);
+
        while ((curtheme = g_dir_read_name(dir_themes))) { //TODO: do this in a separate function
                if ( g_strcmp0(
                        g_ascii_strdown(curtheme,-1),
@@ -131,7 +142,7 @@ void loadThemeComboBox(GtkComboBox *combo, gchar *active_theme) {
        gtk_combo_box_set_model( combo, GTK_TREE_MODEL(store) );
     g_object_unref( G_OBJECT( store ) );
 
-       GtkCellRenderer *cell = gtk_cell_renderer_text_new();
+       cell = gtk_cell_renderer_text_new();
     gtk_cell_layout_pack_start( GTK_CELL_LAYOUT( combo ), cell, TRUE );
     gtk_cell_layout_set_attributes( GTK_CELL_LAYOUT( combo ), cell, "text",1, NULL );
 
diff --git a/gnome-applets/window-buttons/window-buttons.c b/gnome-applets/window-buttons/window-buttons.c
index 8a2881955..b18fb03df 100755
--- a/gnome-applets/window-buttons/window-buttons.c
+++ b/gnome-applets/window-buttons/window-buttons.c
@@ -142,12 +142,17 @@ static WnckWindow *getRootWindow (WnckScreen *screen) {
 }
 
 /* Returns the highest maximized window */
-static WnckWindow *getUpperMaximized (WBApplet *wbapplet) {
+static WnckWindow *
+getUpperMaximized (WBApplet *wbapplet)
+{
+       GList *windows;
+       WnckWindow *returnwindow;
+
        if (!wbapplet->prefs->only_maximized)
                return wbapplet->activewindow;
 
-       GList *windows = wnck_screen_get_windows_stacked(wbapplet->activescreen);
-       WnckWindow *returnwindow = NULL;
+       windows = wnck_screen_get_windows_stacked(wbapplet->activescreen);
+       returnwindow = NULL;
 
        while (windows && windows->data) {
                if (wnck_window_is_maximized(windows->data)) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]