Enlightenment CVS committal

Author  : andreas99
Project : e16
Module  : tools

Dir     : e16/tools/e16menuedit2/src


Modified Files:
        e16menu.c e16menu.h e16menuedit2.c e16menuedit2.h treeview.c 


Log Message:
- GtkStatusbar now used
- better menu check and error handling

===================================================================
RCS file: /cvsroot/enlightenment/e16/tools/e16menuedit2/src/e16menu.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -3 -r1.2 -r1.3
--- e16menu.c   6 Aug 2004 19:18:43 -0000       1.2
+++ e16menu.c   7 Aug 2004 17:08:31 -0000       1.3
@@ -24,14 +24,16 @@
  *
  */
  
- #include <stdio.h>
- #include <errno.h>
- #include "e16menu.h"
- #include "file.h"
- #include "e16menuedit2.h"
- #include "treeview.h"
+#include <stdio.h>
+#include "e16menu.h"
+#include "file.h"
+#include "e16menuedit2.h"
+#include "treeview.h"
  
- GtkTreeModel *load_menus_from_disk (void)
+int app_errno;
+char app_errno_str[APP_ERRNO_STR_LEN];
+ 
+GtkTreeModel *load_menus_from_disk (void)
 {
 
   FILE *menufile;
@@ -366,7 +368,8 @@
   has_child = gtk_tree_model_iter_has_child (model, iter);
   depth = gtk_tree_path_get_depth (path) - 1;
 
-  errno = 0;
+  app_errno = 0;
+  strcpy (app_errno_str, "");
 
   if (depth + 1 >= MAX_RECURSION)
   {
@@ -381,7 +384,9 @@
       /* some checks for submenus */
       if (!strcmp (params, ""))
       {
-       errno = 1;
+       app_errno = AE_EMPTY_SUBMENU;
+       strncpy (app_errno_str, tree_path_str, APP_ERRNO_STR_LEN);
+      
        return TRUE;
       }
     }
===================================================================
RCS file: /cvsroot/enlightenment/e16/tools/e16menuedit2/src/e16menu.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -3 -r1.2 -r1.3
--- e16menu.h   6 Aug 2004 19:18:43 -0000       1.2
+++ e16menu.h   7 Aug 2004 17:08:31 -0000       1.3
@@ -33,6 +33,14 @@
 #endif
 
 #define MAX_RECURSION 128
+#define APP_ERRNO_STR_LEN 1024
+
+/* app_errno codes */
+enum
+{
+  AE_NO_ERROR = 0,
+  AE_EMPTY_SUBMENU
+};
 
 GtkTreeModel *load_menus_from_disk (void);
 void load_sub_menu_from_disk (char *file_to_load, GtkTreeStore *store,
===================================================================
RCS file: /cvsroot/enlightenment/e16/tools/e16menuedit2/src/e16menuedit2.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -3 -r1.9 -r1.10
--- e16menuedit2.c      4 Aug 2004 23:08:27 -0000       1.9
+++ e16menuedit2.c      7 Aug 2004 17:08:31 -0000       1.10
@@ -27,25 +27,26 @@
 #include <unistd.h>
 #include <sys/types.h>
 #include <string.h>
+#include <stdarg.h>
 #include "e16menuedit2.h"
 #include "file.h"
 #include "callbacks.h"
 #include "e16menu.h"
 #include "treeview.h"
-#include <glib-object.h>
 
 int librsvg_cmp;
 
 int main (int argc, char *argv[])
 {
-  GladeXML *main_xml;  
+  GladeXML *main_xml;
   GtkWidget *main_window;
   GtkWidget *treeview_menu;
+  GtkWidget *main_statusbar;
   char app_dir[PATH_MAX];
   char package[] = "librsvg-2.0";
   char good_version[] = "2.7.1";
   char *version;
-  int i;
+  int i;  
 
 #ifdef ENABLE_NLS
   bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
@@ -61,13 +62,13 @@
   }
 
   main_xml = glade_xml_new (PACKAGE_DATA_DIR"/"PACKAGE"/glade/e16menuedit2.glade",
-                                                "main_window", NULL);
-  
+                            "main_window", NULL);
+
   register_libglade_parent (main_xml, "main_window");
-  
+
 
   glade_xml_signal_autoconnect (main_xml);
-  
+
 
   main_window = lookup_libglade_widget ("main_window", "main_window");
 
@@ -92,6 +93,26 @@
   librsvg_cmp = version_cmp (version, good_version);
   g_free (version);
 
+  print_statusbar (_("Menu successfully loaded!"));
+
   gtk_main ();
   return 0;
 }
+
+void print_statusbar (const gchar *format, ...)
+{
+  const int statusbar_len = 100;
+  va_list ap;
+  gchar str[statusbar_len];
+  GtkWidget *main_statusbar;
+
+  va_start (ap, format);
+
+  g_vsnprintf (str, statusbar_len, format, ap);
+
+  main_statusbar = lookup_libglade_widget ("main_window", "main_statusbar");
+
+  gtk_statusbar_push (GTK_STATUSBAR (main_statusbar),
+                      0,
+                      str);
+}
===================================================================
RCS file: /cvsroot/enlightenment/e16/tools/e16menuedit2/src/e16menuedit2.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -3 -r1.4 -r1.5
--- e16menuedit2.h      2 Aug 2004 19:36:15 -0000       1.4
+++ e16menuedit2.h      7 Aug 2004 17:08:31 -0000       1.5
@@ -41,4 +41,6 @@
 #define APP_HOME ".e16menuedit2"
 #define ICON_DIR "icons"
 
+void print_statusbar (const gchar *format, ...);
+
 #endif /* _E16MENUEDIT_H */
===================================================================
RCS file: /cvsroot/enlightenment/e16/tools/e16menuedit2/src/treeview.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -3 -r1.3 -r1.4
--- treeview.c  6 Aug 2004 19:18:43 -0000       1.3
+++ treeview.c  7 Aug 2004 17:08:31 -0000       1.4
@@ -25,12 +25,14 @@
  */
 
 #include <string.h>
-#include <errno.h>
 #include "treeview.h"
 #include "e16menu.h"
 #include "callbacks.h"
 #include "nls.h"
 
+extern int app_errno;
+extern char app_errno_str[APP_ERRNO_STR_LEN];
+
 static GtkTargetEntry row_targets[] =
   {
     { "GTK_TREE_MODEL_ROW", GTK_TARGET_SAME_APP,
@@ -189,11 +191,11 @@
   model = gtk_tree_view_get_model (GTK_TREE_VIEW (treeview_menu));
   gtk_tree_model_foreach (GTK_TREE_MODEL(model), table_check_func, NULL);
 
-  if (errno == 0)
+  if (app_errno == AE_NO_ERROR)
   {
     gtk_tree_model_foreach (GTK_TREE_MODEL(model), table_save_func, NULL);
-    g_print ("Menu saved!\n");
-  
+    print_statusbar (_("Menu saved!"));
+
     /* free allocated menu files */
     while (menu_file[i] != NULL)
     {
@@ -203,9 +205,19 @@
   }
   else
   {
-    g_print ("some error occurred while checking menu!\nmenu not saved!\n");
+    if (app_errno == AE_EMPTY_SUBMENU)
+    {
+      gtk_tree_view_set_cursor (GTK_TREE_VIEW (treeview_menu),
+                                gtk_tree_path_new_from_string  (app_errno_str),
+                                gtk_tree_view_get_column (
+                                  GTK_TREE_VIEW (treeview_menu),
+                                  COL_PARAMS),
+                                TRUE);
+      print_statusbar (_("Submenu must have a name! -> menu not saved!"));
+    }
+    else
+    {
+      print_statusbar (_("Unknown error occurred while checking menu -> menu not 
saved!"));
+    }
   }
-
-
-
 }




-------------------------------------------------------
This SF.Net email is sponsored by OSTG. Have you noticed the changes on
Linux.com, ITManagersJournal and NewsForge in the past few weeks? Now,
one more big change to announce. We are now OSTG- Open Source Technology
Group. Come see the changes on the new OSTG site. www.ostg.com
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to