[gnome-applets] window-buttons: make some functions static



commit 90b53b088c321d420b9675019ecc760d0da5947e
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Tue Mar 28 15:15:14 2017 +0300

    window-buttons: make some functions static

 window-buttons/preferences.c   |  189 +++++++++++++++++++++++++---------------
 window-buttons/theme.c         |   56 ++++++------
 window-buttons/windowbuttons.c |   18 +++--
 3 files changed, 156 insertions(+), 107 deletions(-)
---
diff --git a/window-buttons/preferences.c b/window-buttons/preferences.c
index b421d23..eed29f1 100755
--- a/window-buttons/preferences.c
+++ b/window-buttons/preferences.c
@@ -20,41 +20,73 @@
 
 #include "preferences.h"
 
-/* prototypes */
-void cb_only_maximized (GtkButton *, WBApplet *);
-void cb_click_effect (GtkButton *, WBApplet *);
-void cb_hover_effect (GtkButton *, WBApplet *);
-void cb_hide_on_unmaximized (GtkButton *, WBApplet *);
-void cb_hide_decoration (GtkButton *, WBApplet *);
-void cb_btn_minimize_hidden (GtkButton *, WBApplet *);
-void cb_btn_maximize_hidden (GtkButton *, WBApplet *);
-void cb_btn_close_hidden (GtkButton *, WBApplet *);
-void properties_close (GtkButton *, WBApplet *);
 void updateImages(WBApplet *);
-void savePreferences(WBPreferences *, WBApplet *);
 void loadThemeComboBox(GtkComboBox *, gchar *);
 void loadThemeButtons(GtkWidget ***, GdkPixbuf ***, gchar ***);
 void toggleCompizDecoration(gboolean);
 void reloadButtons(WBApplet *);
-const gchar *getImageCfgKey (gushort, gushort);
-const gchar *getCheckBoxCfgKey (gushort);
-const gchar *getImageCfgKey(gushort, gushort);
 const gchar* getButtonImageState(int, const gchar*);
 const gchar* getButtonImageState4(int);
 const gchar* getButtonImageName(int);
-GtkRadioButton **getOrientationButtons(GtkBuilder *);
-GtkToggleButton **getHideButtons(GtkBuilder *);
 GtkWidget ***getImageButtons(GtkBuilder *);
 GdkPixbuf ***getPixbufs(gchar ***);
 gchar ***getImages(gchar *);
 gchar *getMetacityLayout (void);
-gchar *getCfgValue(FILE *, gchar *);
-gchar *fixThemeName(gchar *);
 gshort *getEBPos(gchar *);
 WBPreferences *loadPreferences(WBApplet *);
 gboolean issetCompizDecoration(void);
 
-void savePreferences(WBPreferences *wbp, WBApplet *wbapplet) {
+#if PLAINTEXT_CONFIG != 0
+static gchar *
+getCfgValue (FILE  *f,
+             gchar *key)
+{
+  gchar tmp[256] = { 0x0 };
+  long int pos = ftell (f);
+  gchar *r;
+
+  while (f != NULL && fgets (tmp, sizeof (tmp), f) != NULL)
+    {
+      if (g_strrstr (tmp, key))
+        break;
+    }
+
+  r = g_strndup (tmp + strlen (key) + 1, strlen (tmp) - strlen (key) + 1);
+  g_strstrip (r);
+
+  fseek (f, pos, SEEK_SET);
+  return r;
+}
+#endif
+
+static const gchar *
+getCheckBoxCfgKey (gushort checkbox_id)
+{
+  switch (checkbox_id)
+    {
+      case 0:
+        return CFG_MINIMIZE_HIDDEN;
+      case 1:
+        return CFG_UNMAXIMIZE_HIDDEN;
+      case 2:
+        return CFG_CLOSE_HIDDEN;
+      default:
+        return NULL;
+    }
+}
+
+static const gchar *
+getImageCfgKey (gushort image_state,
+                gushort image_index)
+{
+  return g_strconcat ("btn-", getButtonImageState(image_state,"-"),
+                      "-", getButtonImageName(image_index), NULL);
+}
+
+static void
+savePreferences (WBPreferences *wbp,
+                 WBApplet      *wbapplet)
+{
 #if PLAINTEXT_CONFIG == 0
        gint i, j;
 
@@ -213,25 +245,6 @@ WBPreferences *loadPreferences(WBApplet *wbapplet) {
        return wbp;
 }
 
-#if PLAINTEXT_CONFIG != 0
-/* Returns a string value of the specified configuration parameter (key) */
-gchar* getCfgValue(FILE *f, gchar *key) {
-    gchar tmp[256] = {0x0};
-       long int pos = ftell(f);
-
-    while (f!=NULL && fgets(tmp,sizeof(tmp),f)!=NULL) {
-               if (g_strrstr(tmp, key))
-                   break;
-    }
-
-       gchar *r = g_strndup(tmp+strlen(key)+1,strlen(tmp)-strlen(key)+1);
-       g_strstrip(r);
-
-       fseek(f,pos,SEEK_SET);
-    return r;
-}
-#endif
-
 /* Parses Metacity's GSettings entry to get the button order */
 gshort *getEBPos(gchar *button_layout) {
        gshort *ebps = g_new(gshort, WB_BUTTONS);
@@ -256,15 +269,6 @@ gshort *getEBPos(gchar *button_layout) {
        return ebps;
 }
 
-const gchar* getCheckBoxCfgKey(gushort checkbox_id) {
-       switch (checkbox_id) {
-               case 0: return CFG_MINIMIZE_HIDDEN;
-               case 1: return CFG_UNMAXIMIZE_HIDDEN;
-               case 2: return CFG_CLOSE_HIDDEN;
-               default: return NULL;
-       }
-}
-
 /* Returns a 2D array of GtkWidget image buttons */
 GtkWidget ***getImageButtons(GtkBuilder *prefbuilder) {
        gint i,j;
@@ -278,7 +282,9 @@ GtkWidget ***getImageButtons(GtkBuilder *prefbuilder) {
        return btn;
 }
 
-GtkToggleButton **getHideButtons(GtkBuilder *prefbuilder) {
+static GtkToggleButton **
+getHideButtons (GtkBuilder *prefbuilder)
+{
        GtkToggleButton **chkb_btn_hidden = g_new(GtkToggleButton*, WB_BUTTONS);
        chkb_btn_hidden[0] = GTK_TOGGLE_BUTTON (gtk_builder_get_object(prefbuilder, "cb_btn0_visible")),
        chkb_btn_hidden[1] = GTK_TOGGLE_BUTTON (gtk_builder_get_object(prefbuilder, "cb_btn1_visible")),
@@ -286,7 +292,9 @@ GtkToggleButton **getHideButtons(GtkBuilder *prefbuilder) {
        return chkb_btn_hidden;
 }
 
-GtkRadioButton **getOrientationButtons(GtkBuilder *prefbuilder) {
+static GtkRadioButton **
+getOrientationButtons (GtkBuilder *prefbuilder)
+{
        GtkRadioButton **radio_orientation = g_new(GtkRadioButton*, 3);
        radio_orientation[0] = GTK_RADIO_BUTTON (gtk_builder_get_object(prefbuilder, 
"orientation_automatic")),
        radio_orientation[1] = GTK_RADIO_BUTTON (gtk_builder_get_object(prefbuilder, 
"orientation_horizontal")),
@@ -294,7 +302,10 @@ GtkRadioButton **getOrientationButtons(GtkBuilder *prefbuilder) {
        return radio_orientation;
 }
 
-void select_new_image (GtkButton *object, gpointer user_data) {
+static void
+select_new_image (GtkButton *object,
+                  gpointer   user_data)
+{
        GtkWidget *fileopendialog;
        ImageOpenData *iod = (ImageOpenData*)user_data;
        WBApplet *wbapplet = iod->wbapplet;
@@ -337,38 +348,59 @@ void select_new_image (GtkButton *object, gpointer user_data) {
        gtk_widget_destroy (fileopendialog);
 }
 
-void cb_only_maximized(GtkButton *button, WBApplet *wbapplet) {
+static void
+cb_only_maximized (GtkButton *button,
+                   WBApplet  *wbapplet)
+{
        wbapplet->prefs->only_maximized = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(button));
        savePreferences(wbapplet->prefs, wbapplet);
 }
 
-void cb_click_effect(GtkButton *button, WBApplet *wbapplet) {
+static void
+cb_click_effect (GtkButton *button,
+                 WBApplet  *wbapplet)
+{
        wbapplet->prefs->click_effect = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(button));
        savePreferences(wbapplet->prefs, wbapplet);
 }
 
-void cb_hover_effect(GtkButton *button, WBApplet *wbapplet) {
+static void
+cb_hover_effect (GtkButton *button,
+                 WBApplet  *wbapplet)
+{
        wbapplet->prefs->hover_effect = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(button));
        savePreferences(wbapplet->prefs, wbapplet);
 }
 
-void cb_reverse_order(GtkButton *button, WBApplet *wbapplet) {
+static void
+cb_reverse_order (GtkButton *button,
+                  WBApplet  *wbapplet)
+{
        wbapplet->prefs->reverse_order = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(button));
        reloadButtons(wbapplet);
        savePreferences(wbapplet->prefs, wbapplet);
 }
 
-void cb_hide_on_unmaximized(GtkButton *button, WBApplet *wbapplet) {
+static void
+cb_hide_on_unmaximized (GtkButton *button,
+                        WBApplet  *wbapplet)
+{
        wbapplet->prefs->hide_on_unmaximized = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(button));
        updateImages(wbapplet);
        savePreferences(wbapplet->prefs, wbapplet);
 }
 
-void cb_hide_decoration(GtkButton *button, WBApplet *wbapplet) {
+static void
+cb_hide_decoration (GtkButton *button,
+                    WBApplet  *wbapplet)
+{
        toggleCompizDecoration(!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button)));
 }
 
-void cb_show_tooltips(GtkButton *button, WBApplet *wbapplet) {
+static void
+cb_show_tooltips (GtkButton *button,
+                  WBApplet  *wbapplet)
+{
        wbapplet->prefs->show_tooltips = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(button));
        gint i;
        for (i=0; i<WB_BUTTONS; i++)
@@ -376,7 +408,10 @@ void cb_show_tooltips(GtkButton *button, WBApplet *wbapplet) {
        savePreferences(wbapplet->prefs, wbapplet);
 }
 
-void cb_btn_hidden(GtkButton *button, gpointer user_data) {
+static void
+cb_btn_hidden (GtkButton *button,
+               gpointer   user_data)
+{
        CheckBoxData *cbd = (CheckBoxData*)user_data;
        WBApplet *wbapplet = cbd->wbapplet;
 
@@ -390,8 +425,10 @@ void cb_btn_hidden(GtkButton *button, gpointer user_data) {
        savePreferences(wbapplet->prefs, wbapplet);
 }
 
-// "Use Metacity's button order" checkbox
-void cb_metacity_layout(GtkButton *button, WBApplet *wbapplet) {
+static void
+cb_metacity_layout (GtkButton *button,
+                    WBApplet  *wbapplet)
+{
        GtkEntry *entry_custom_layout = GTK_ENTRY (gtk_builder_get_object(wbapplet->prefbuilder, 
CFG_BUTTON_LAYOUT));
 
        if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(button))) {
@@ -411,8 +448,10 @@ void cb_metacity_layout(GtkButton *button, WBApplet *wbapplet) {
        reloadButtons (wbapplet);
 }
 
-// "Reload" button clicked
-void cb_reload_buttons(GtkButton *button, WBApplet *wbapplet) {
+static void
+cb_reload_buttons (GtkButton *button,
+                   WBApplet  *wbapplet)
+{
        GtkEntry *entry_custom_layout = GTK_ENTRY (gtk_builder_get_object(wbapplet->prefbuilder, 
CFG_BUTTON_LAYOUT));
        gchar *new_layout = g_strdup(gtk_entry_get_text(entry_custom_layout));
        wbapplet->prefs->button_layout = new_layout;
@@ -421,7 +460,10 @@ void cb_reload_buttons(GtkButton *button, WBApplet *wbapplet) {
        reloadButtons(wbapplet);
 }
 
-static void cb_theme_changed(GtkComboBox *combo, WBApplet *wbapplet) {
+static void
+cb_theme_changed (GtkComboBox *combo,
+                  WBApplet    *wbapplet)
+{
        WBPreferences *wbp = wbapplet->prefs;
        GtkTreeIter   iter;
     gchar        *theme = NULL;
@@ -441,7 +483,10 @@ static void cb_theme_changed(GtkComboBox *combo, WBApplet *wbapplet) {
        savePreferences(wbp, wbapplet);
 }
 
-void cb_orientation(GtkRadioButton *style, WBApplet *wbapplet) {
+static void
+cb_orientation (GtkRadioButton *style,
+                WBApplet       *wbapplet)
+{
        // This thing gets executed twice with every selection
        // (Supposedly this is going to be resolved with GtkRadioGroup in later versions of GTK+)
        // So we need to eliminate the "untoggle" event
@@ -462,8 +507,14 @@ void cb_orientation(GtkRadioButton *style, WBApplet *wbapplet) {
        }
 }
 
-/* The Preferences Dialog */
-//void properties_cb(BonoboUIComponent *uic, WBApplet *wbapplet, const char *verb) {
+static void
+properties_close (GtkButton *object,
+                  WBApplet  *wbapplet)
+{
+  gtk_widget_destroy(wbapplet->window_prefs);
+  wbapplet->window_prefs = NULL;
+}
+
 void properties_cb (GSimpleAction *action, GVariant *parameter, gpointer user_data) {
        WBApplet *wbapplet;
        GtkWidget               ***btn;
@@ -558,9 +609,3 @@ void properties_cb (GSimpleAction *action, GVariant *parameter, gpointer user_da
 
        gtk_widget_show (wbapplet->window_prefs);
 }
-
-/* Close the Properties dialog - we're not saving anything (it's already saved) */
-void properties_close (GtkButton *object, WBApplet *wbapplet) {
-       gtk_widget_destroy(wbapplet->window_prefs);
-       wbapplet->window_prefs = NULL;
-}
diff --git a/window-buttons/theme.c b/window-buttons/theme.c
index 9021065..9c047c6 100755
--- a/window-buttons/theme.c
+++ b/window-buttons/theme.c
@@ -22,14 +22,40 @@
 
 void loadThemeComboBox(GtkComboBox *, gchar *);
 void loadThemeButtons(GtkWidget ***, GdkPixbuf ***, gchar ***);
-const gchar *getImageCfgKey(gushort, gushort);
 const gchar* getButtonImageState(int, const gchar*);
 const gchar* getButtonImageState4(int);
 const gchar* getButtonImageName(int);
 GdkPixbuf ***getPixbufs(gchar ***);
 gchar ***getImages(gchar *);
-gchar *fixThemeName(gchar *);
 
+static gchar *
+fixThemeName (gchar *theme_name)
+{
+  gchar prev;
+  gint len = strlen(theme_name);
+  gint i;
+
+  if (len > 1)
+    {
+      prev = '-';
+
+      for (i = 0; i < len; i++)
+        {
+          if (prev == '-')
+            theme_name[i] = g_ascii_toupper (theme_name[i]);
+
+          prev = theme_name[i];
+        }
+
+      return theme_name;
+    }
+  else if (len == 1)
+    {
+      return g_ascii_strup (theme_name, 1);
+    }
+
+  return NULL;
+}
 
 const gchar* getButtonImageName(int button_id) {
        switch (button_id) {
@@ -64,12 +90,6 @@ const gchar* getButtonImageState4(int state_id) { // old 4-state mode for backwa
        }
 }
 
-/* returns the image key string */
-const gchar *getImageCfgKey(gushort image_state, gushort image_index) {
-       return g_strconcat("btn-", getButtonImageState(image_state,"-"), "-", 
getButtonImageName(image_index), NULL);
-}
-
-
 /* Load the themes into a combo Box */
 void loadThemeComboBox(GtkComboBox *combo, gchar *active_theme) {
        GtkTreeIter             iter;
@@ -163,23 +183,3 @@ GdkPixbuf ***getPixbufs(gchar ***images) {
        }
        return pixbufs;
 }
-
-gchar *fixThemeName(gchar *theme_name) {
-       gchar prev;
-       gint len = strlen(theme_name);
-       gint i;
-
-       if (len > 1) {
-               prev = '-';
-               for (i=0; i<len; i++) {
-                       if (prev == '-') theme_name[i] = g_ascii_toupper(theme_name[i]);
-                       prev = theme_name[i];
-               }
-
-               return theme_name;
-       } else if (len == 1) {
-               return g_ascii_strup(theme_name,1);
-       } else {
-               return NULL;
-       }
-}
diff --git a/window-buttons/windowbuttons.c b/window-buttons/windowbuttons.c
index d97e0da..9fc5ad1 100755
--- a/window-buttons/windowbuttons.c
+++ b/window-buttons/windowbuttons.c
@@ -42,12 +42,10 @@ void rotatePixbufs(WBApplet *);
 void placeButtons(WBApplet *);
 void reloadButtons(WBApplet *);
 void toggleHidden(WBApplet *);
-void savePreferences(WBPreferences *, WBApplet *);
 void loadThemes(GtkComboBox *, gchar *);
 WBPreferences *loadPreferences(WBApplet *);
 //gchar *getButtonLayoutGConf(WBApplet *, gboolean);
 gchar *getMetacityLayout(void);
-const gchar *getCheckBoxCfgKey (gushort);
 GdkPixbuf ***getPixbufs(gchar ***);
 
 //G_DEFINE_TYPE(TN, t_n, T_P) G_DEFINE_TYPE_EXTENDED (TN, t_n, T_P, 0, {})
@@ -172,8 +170,9 @@ static WnckWindow *getUpperMaximized (WBApplet *wbapplet) {
        return returnwindow;
 }
 
-/* Return image ID according to button state */
-gushort getImageState (WBButtonState button_state) {
+static gushort
+getImageState (WBButtonState button_state)
+{
        if (button_state & WB_BUTTON_STATE_FOCUSED) {
                if (button_state & WB_BUTTON_STATE_CLICKED) {
                        return WB_IMAGE_FOCUSED_CLICKED;
@@ -497,7 +496,9 @@ static gboolean hover_leave (GtkWidget *widget,
        return TRUE;
 }
 
-WindowButton **createButtons (WBApplet *wbapplet) {
+static WindowButton **
+createButtons (WBApplet *wbapplet)
+{
        WindowButton **button = g_new(WindowButton*, WB_BUTTONS);
        gint i;
 
@@ -617,8 +618,11 @@ void reloadButtons(WBApplet *wbapplet) {
        }
 }
 
-/* Triggered when a different panel orientation is detected */
-void applet_change_orient (PanelApplet *panelapplet, PanelAppletOrient orient, WBApplet *wbapplet) {
+static void
+applet_change_orient (PanelApplet       *panelapplet,
+                      PanelAppletOrient  orient,
+                      WBApplet          *wbapplet)
+{
        if (orient != wbapplet->orient) {
                wbapplet->orient = orient;
                wbapplet->pixbufs = getPixbufs(wbapplet->prefs->images);


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