[Goodies-commits] r2382 - in xfce4-xkb-plugin/trunk: . panel-plugin

Nick Schermer nick at xfce.org
Tue Jan 16 19:54:02 CET 2007


Author: nick
Date: 2007-01-16 18:54:01 +0000 (Tue, 16 Jan 2007)
New Revision: 2382

Modified:
   xfce4-xkb-plugin/trunk/ChangeLog
   xfce4-xkb-plugin/trunk/configure.ac
   xfce4-xkb-plugin/trunk/panel-plugin/Makefile.am
   xfce4-xkb-plugin/trunk/panel-plugin/xfce4-xkb-plugin.c
   xfce4-xkb-plugin/trunk/panel-plugin/xkb.c
   xfce4-xkb-plugin/trunk/panel-plugin/xkb.h
Log:
Fix compiler warning and a couple of other problems.

Modified: xfce4-xkb-plugin/trunk/ChangeLog
===================================================================
--- xfce4-xkb-plugin/trunk/ChangeLog	2007-01-16 18:30:32 UTC (rev 2381)
+++ xfce4-xkb-plugin/trunk/ChangeLog	2007-01-16 18:54:01 UTC (rev 2382)
@@ -1,3 +1,7 @@
+2007-01-16 19:52  Nick Schermer <nick at xfce.org>
+
+	* Fix compiler warning and a couple of other problems.
+
 2006-12-06 17:40  sasoiliev
 
 	* configure.ac: updated version to 0.4.2

Modified: xfce4-xkb-plugin/trunk/configure.ac
===================================================================
--- xfce4-xkb-plugin/trunk/configure.ac	2007-01-16 18:30:32 UTC (rev 2381)
+++ xfce4-xkb-plugin/trunk/configure.ac	2007-01-16 18:54:01 UTC (rev 2382)
@@ -36,6 +36,9 @@
 XDT_CHECK_LIBX11_REQUIRE
 
 dnl configure the panel plugin
+XDT_CHECK_PACKAGE([GTK], [gtk+-2.0], [2.6.0])
+XDT_CHECK_PACKAGE([LIBXFCE4UTIL], [libxfce4util-1.0], [4.3.90.2])
+XDT_CHECK_PACKAGE([LIBXFCEGUI4], [libxfcegui4-1.0], [4.3.90.2])
 XDT_CHECK_PACKAGE([LIBXFCE4PANEL], [libxfce4panel-1.0], [4.3.20])
 
 dnl Check for i18n support

Modified: xfce4-xkb-plugin/trunk/panel-plugin/Makefile.am
===================================================================
--- xfce4-xkb-plugin/trunk/panel-plugin/Makefile.am	2007-01-16 18:30:32 UTC (rev 2381)
+++ xfce4-xkb-plugin/trunk/panel-plugin/Makefile.am	2007-01-16 18:54:01 UTC (rev 2382)
@@ -1,3 +1,8 @@
+
+INCLUDES =										\
+	-DPACKAGE_LOCALE_DIR=\"$(localedir)\"						\
+	-DFLAGSDIR=\"$(datadir)/xfce4/xkb/flags\"
+
 plugindir = $(libexecdir)/xfce4/panel-plugins
 
 plugin_PROGRAMS = xfce4-xkb-plugin
@@ -3,16 +8,20 @@
 
 xfce4_xkb_plugin_SOURCES =								\
-	xfce4-xkb-plugin.c											\
+	xfce4-xkb-plugin.c								\
 	xkb.c																		\
 	xkb.h
 
-xfce4_xkb_plugin_CFLAGS =									\
-	@LIBXFCE4PANEL_CFLAGS@          				\
-	-DPACKAGE_LOCALE_DIR=\"$(localedir)\"				\
-	-DFLAGSDIR=\"$(datadir)/xfce4/xkb/flags\"
+xfce4_xkb_plugin_CFLAGS =								\
+	@LIBXFCE4PANEL_CFLAGS@								\
+	@GTK_CFLAGS@									\
+	@LIBXFCEGUI4_CFLAGS@								\
+	@LIBXFCE4UTIL_CFLAGS@
+	
 
-xfce4_xkb_plugin_LDADD = 									\
-	@LIBXFCE4PANEL_LIBS@										\
-	@LIBS@
+xfce4_xkb_plugin_LDADD = 								\
+	@LIBXFCE4PANEL_LIBS@								\
+	@GTK_LIBS@									\
+	@LIBXFCEGUI4_LIBS@								\
+	@LIBXFCE4UTIL_LIBS@
 
 desktop_in_in_files = xkb-plugin.desktop.in.in
@@ -26,7 +35,7 @@
 EXTRA_DIST =															\
 	$(desktop_in_in_files)
 
-DISTCLEANFILES = 													\
+DISTCLEANFILES = 									\
 	$(desktop_DATA) $(desktop_in_files)
 
 %.desktop.in: %.desktop.in.in

Modified: xfce4-xkb-plugin/trunk/panel-plugin/xfce4-xkb-plugin.c
===================================================================
--- xfce4-xkb-plugin/trunk/panel-plugin/xfce4-xkb-plugin.c	2007-01-16 18:30:32 UTC (rev 2381)
+++ xfce4-xkb-plugin/trunk/panel-plugin/xfce4-xkb-plugin.c	2007-01-16 18:54:01 UTC (rev 2382)
@@ -122,9 +122,16 @@
 xfce_xkb_set_size(XfcePanelPlugin *plugin, gint size,
                   t_xkb *xkb)
 {
+  GtkOrientation orientation;
   DBG ("setting size %d", size);
   xkb->size = size;
-  gtk_widget_set_size_request(xkb->btn, xkb->size, xkb->size);
+  
+  orientation = xfce_panel_plugin_get_orientation (plugin);
+  if (orientation == GTK_ORIENTATION_HORIZONTAL)
+    gtk_widget_set_size_request(xkb->btn, -1, xkb->size);
+  else
+    gtk_widget_set_size_request(xkb->btn, xkb->size, -1);
+  
   set_new_locale(xkb);
   return TRUE;
 }
@@ -288,7 +295,7 @@
 {
   t_xkb *xkb;
   gchar *filename;
-  char *initial_group;
+  const char *initial_group;
   NetkScreen* netk_screen;
 
   xkb = g_new(t_xkb, 1);
@@ -354,7 +361,7 @@
 
   g_return_if_fail(xkb != NULL);
 
-  g_object_unref(xkb->btn);
+  gtk_widget_destroy(xkb->btn);
 
   g_free(xkb);
 }
@@ -399,7 +406,7 @@
 xkb_options_dlg_create()
 {
   int x;
-  GtkWidget *vbox, *hbox, *label, *opt_menu, *display_type_frame,
+  GtkWidget *vbox, *hbox, *display_type_frame,
             *per_app_frame, *alignment1, *alignment2, *hbox3, *label4;
 
   dlg = g_new0(t_xkb_options_dlg, 1);

Modified: xfce4-xkb-plugin/trunk/panel-plugin/xkb.c
===================================================================
--- xfce4-xkb-plugin/trunk/panel-plugin/xkb.c	2007-01-16 18:30:32 UTC (rev 2381)
+++ xfce4-xkb-plugin/trunk/panel-plugin/xkb.c	2007-01-16 18:54:01 UTC (rev 2382)
@@ -21,6 +21,7 @@
 #include <X11/XKBlib.h>
 
 #include <gtk/gtk.h>
+#include <gdk-pixbuf/gdk-pixbuf.h>
 #include <glib.h>
 
 Display *dsp;
@@ -50,26 +51,6 @@
   return group_count;
 }
 
-char*
-to_upper(char *src) 
-{
-  int i = 0;
-  for (i = 0; i < strlen(src); i++) {
-    src[i] = toupper(src[i]);
-  }
-  return src;
-}
-
-char*
-to_lower(char *src) 
-{
-  int i = 0;
-  for (i = 0; i < strlen(src); i++) {
-    src[i] = tolower(src[i]);
-  }
-  return src;
-}
-
 static int 
 group_lookup(int source_value, char *from_texts[], char *to_texts[], int count) 
 {
@@ -106,22 +87,23 @@
   return group_lookup(group_res_no, group_codes, symbol_names, group_count);
 }
 
-static char * 
+static const char * 
 get_group_name_by_res_no(int group_res_no) 
 {
   return group_names[group_no_res_to_xkb(group_res_no)];
 }
 
-char * 
+const char * 
 get_symbol_name_by_res_no(int group_res_no) 
 {
   return symbol_names[group_no_res_to_xkb(group_res_no)];
 }
 
-const char *
-get_current_group_name() 
+static char *
+get_current_group_name(void) 
 {
-  return get_symbol_name_by_res_no(current_group_xkb_no);
+  const char *tmp = get_symbol_name_by_res_no(current_group_xkb_no);
+  return g_utf8_strdown (tmp, -1);
 }
 
 void 
@@ -216,7 +198,7 @@
     ptr1 = strchr(ptr, '(');
     if (ptr1 != NULL) *ptr1 = '\0';
     ptr1 = strchr(ptr, '_');
-    if (ptr1 != NULL && !isupper(*(ptr1+1))) *ptr1 = '\0';
+    if (ptr1 != NULL && !g_ascii_isupper((int) *(ptr1+1))) *ptr1 = '\0';
     ptr1 = strchr(ptr, ':');
     if (ptr1 != NULL) *ptr1 = '\0';
 
@@ -233,7 +215,7 @@
         /* Filter cases like pc(pc105) (Xorg 7.0 update) */
         if (strncmp(ptr, "pc", 2) == 0) continue;
         
-    symbol_names[count++] = to_upper(strdup(ptr));
+    symbol_names[count++] = g_utf8_strup(ptr, -1);
   }
 
   if (count == 1 && group_names[0] == NULL &&
@@ -263,7 +245,7 @@
     switch(group_title_source) {
       case 1: /* Group name */
         if (group_names[i] == NULL) {
-          char *name = get_symbol_name_by_res_no(i);
+          const char *name = get_symbol_name_by_res_no(i);
           if (name == NULL) name = "U/A";
           fprintf(stderr, "\nGroup Name %i is undefined, set to '%s' !\n", i+1, name);
           group_names[i] = strdup(name);
@@ -302,15 +284,20 @@
 gboolean temporary_changed_display_type = FALSE;
 
 gboolean 
-is_current_group_flag_available() 
+is_current_group_flag_available(void) 
 {
   char *filename;
   gboolean result = FALSE;
-  filename = g_strdup_printf("%s/%s.png", FLAGSDIR, to_lower(get_current_group_name()));
-  GdkPixbuf *tmp = gdk_pixbuf_new_from_file(filename, NULL);
+  GdkPixbuf *tmp = NULL;
+  char *group_name = get_current_group_name();
+  filename = g_strdup_printf("%s/%s.png", FLAGSDIR, group_name);
+  DBG ("Try to load image: %s", filename);
+  tmp = gdk_pixbuf_new_from_file(filename, NULL);
   g_free(filename);
+  g_free (group_name);
   result = (gboolean) (tmp != NULL);
-  g_object_unref(tmp);
+  if (tmp)
+    g_object_unref(G_OBJECT (tmp));
   return result;
 }
 
@@ -353,8 +340,9 @@
   t_xkb *plugin = (t_xkb *) ctrl;
   char *filename;
   char *label_markup;
+  char *group_name;
   int size;
-  GdkPixbuf *pixbuf, *tmp;
+  GdkPixbuf *pixbuf = NULL, *tmp = NULL;
   NetkWindow* win;
   gint pid;
 
@@ -362,12 +350,15 @@
   label_markup = xkb_get_label_markup (plugin); 
   gtk_label_set_markup (GTK_LABEL (plugin->label), label_markup);
   g_free(label_markup);
-
+  
   /* Set the image */
   size = 0.9 * plugin->size;
-  filename = g_strdup_printf("%s/%s.png", FLAGSDIR, to_lower(get_current_group_name()));
+  group_name = get_current_group_name();
+  filename = g_strdup_printf("%s/%s.png", FLAGSDIR, group_name);
+  DBG ("Try to load image: %s", filename);
   tmp = gdk_pixbuf_new_from_file(filename, NULL);
   g_free(filename);
+  g_free(group_name);
   if (tmp == NULL) { /* could not be loaded for some reason */
     if (plugin->display_type == IMAGE) {
       temporary_changed_display_type = TRUE;
@@ -378,8 +369,11 @@
     temporary_changed_display_type = TRUE;
     pixbuf = gdk_pixbuf_scale_simple(tmp, size, size - (int) (size / 3), GDK_INTERP_BILINEAR);
     gtk_image_set_from_pixbuf((GtkImage *) plugin->image, pixbuf);
-    g_object_unref(G_OBJECT(tmp));
-    g_object_unref(G_OBJECT(pixbuf));
+    if (tmp)
+      g_object_unref(G_OBJECT(tmp));
+      
+    if (pixbuf)
+      g_object_unref(G_OBJECT(pixbuf));
 
     if (plugin->display_type == IMAGE) { 
       /* the image for the previous active layout could not be loaded */
@@ -421,14 +415,13 @@
   }
 }
 
-char * 
+const char * 
 initialize_xkb(t_xkb *ctrl) 
 {
-  XkbEvent evnt;
   XkbStateRec state;
   int event_code, error_rtrn, major, minor, reason_rtrn;
   char * display_name;
-  char *group;
+  const char *group;
 
   major = XkbMajorVersion;
   minor = XkbMinorVersion;

Modified: xfce4-xkb-plugin/trunk/panel-plugin/xkb.h
===================================================================
--- xfce4-xkb-plugin/trunk/panel-plugin/xkb.h	2007-01-16 18:30:32 UTC (rev 2381)
+++ xfce4-xkb-plugin/trunk/panel-plugin/xkb.h	2007-01-16 18:54:01 UTC (rev 2382)
@@ -72,16 +72,16 @@
 } t_xkb_options_dlg;
 
 void set_new_locale(t_xkb *ctrl);
-char *initialize_xkb(t_xkb *ctrl);
+const char *initialize_xkb(t_xkb *ctrl);
 void deinitialize_xkb();
-
+void react_application_closed(gint pid);
 gint get_group_count();
-char * get_symbol_name_by_res_no(int group_res_no);
+const char * get_symbol_name_by_res_no(int group_res_no);
 
 int do_change_group(int increment, t_xkb *ctrl);
 gboolean gio_callback(GIOChannel *source, GIOCondition condition, gpointer data);
 int get_connection_number();
-
+gboolean is_current_group_flag_available(void);
 /* "locale per process" functions */
 void react_active_window_changed(gint pid, t_xkb *ctrl);
 void react_window_closed(gint pid);




More information about the Goodies-commits mailing list