From: Alexandru C. <cs...@us...> - 2004-10-22 15:38:19
|
Update of /cvsroot/groundstation/grig2/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10231 Modified Files: grig-menubar.c grig-menubar.h Log Message: Created menubar using GtkAction architecture. Removed obsolete GConf androtator related code. Index: grig-menubar.c =================================================================== RCS file: /cvsroot/groundstation/grig2/src/grig-menubar.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** grig-menubar.c 6 Oct 2004 14:05:09 -0000 1.1 --- grig-menubar.c 22 Oct 2004 15:38:09 -0000 1.2 *************** *** 30,33 **** --- 30,34 ---- USA */ + #include <stdlib.h> #include <gtk/gtk.h> #include <hamlib/rig.h> *************** *** 35,38 **** --- 36,40 ---- #include "grig-config.h" #include "grig-menubar.h" + #include "rig-gui-info.h" #include "support.h" *************** *** 40,140 **** extern GtkWidget *grigapp; /* defined in main.c */ ! /* private function prototypes */ - static void grig_menu_rot_open (GtkWidget *, gpointer); static void grig_menu_app_exit (GtkWidget *, gpointer); ! static void grig_menu_set_debug_level (GtkWidget *, gpointer); static void grig_menu_config (GtkWidget *, gpointer); - static void grig_menu_about (GtkWidget *, gpointer); ! /** \brief File menu declaration. */ ! /* GnomeUIInfo grig_file_menu[] = { */ ! /* GNOMEUIINFO_ITEM_DATA (N_("Rotator"), N_("Ope rotator control window"), */ ! /* grig_menu_rot_open, NULL, NULL), */ ! /* GNOMEUIINFO_SEPARATOR, */ ! /* GNOMEUIINFO_MENU_EXIT_ITEM (grig_menu_app_exit, NULL), */ ! /* GNOMEUIINFO_END */ ! /* }; */ - /** \brief rig_set_debug items in a radiolist */ - /* GnomeUIInfo grig_settings_debug_list[] = { */ - /* GNOMEUIINFO_RADIOITEM_DATA (N_("_None"), N_("No debug info"), */ - /* grig_menu_set_debug_level, */ - /* GUINT_TO_POINTER (RIG_DEBUG_NONE), NULL), */ - /* GNOMEUIINFO_RADIOITEM_DATA (N_("_Bug"), N_("Serious bugs"), */ - /* grig_menu_set_debug_level, */ - /* GUINT_TO_POINTER (RIG_DEBUG_BUG), NULL), */ - /* GNOMEUIINFO_RADIOITEM_DATA (N_("_Error"), N_("Error case"), */ - /* grig_menu_set_debug_level, */ - /* GUINT_TO_POINTER (RIG_DEBUG_ERR), NULL), */ - /* GNOMEUIINFO_RADIOITEM_DATA (N_("_Warning"), N_("Also show warnings"), */ - /* grig_menu_set_debug_level, */ - /* GUINT_TO_POINTER (RIG_DEBUG_WARN), NULL), */ - /* GNOMEUIINFO_RADIOITEM_DATA (N_("_Verbose"), N_("Verbose output"), */ - /* grig_menu_set_debug_level, */ - /* GUINT_TO_POINTER (RIG_DEBUG_VERBOSE), NULL), */ - /* GNOMEUIINFO_RADIOITEM_DATA (N_("_Trace"), N_("Print everything"), */ - /* grig_menu_set_debug_level, */ - /* GUINT_TO_POINTER (RIG_DEBUG_TRACE), NULL), */ - /* GNOMEUIINFO_END */ - /* }; */ - /** \brief The submenu containing the debug level radiolist */ - /* GnomeUIInfo grig_settings_debug_submenu[] = { */ - /* GNOMEUIINFO_RADIOLIST (grig_settings_debug_list), */ - /* GNOMEUIINFO_END */ - /* }; */ - /** \brief Settings menu declaration. */ - /* GnomeUIInfo grig_settings_menu[] = { */ - /* GNOMEUIINFO_MENU_PREFERENCES_ITEM (grig_menu_config, NULL), */ - /* GNOMEUIINFO_SEPARATOR, */ - /* GNOMEUIINFO_SUBTREE (N_("_Debug Level"), grig_settings_debug_submenu), */ - /* GNOMEUIINFO_END */ - /* }; */ ! /** \brief The help menu declaration. */ ! /* GnomeUIInfo grig_help_menu[] = { */ ! /* GNOMEUIINFO_HELP ("grig"), */ ! /* GNOMEUIINFO_SEPARATOR, */ ! /* GNOMEUIINFO_MENU_ABOUT_ITEM (grig_menu_about, NULL), */ ! /* GNOMEUIINFO_END */ ! /* }; */ - /** \brief The menubar declaration. */ - /* GnomeUIInfo grig_menubar[] = { */ - /* GNOMEUIINFO_MENU_FILE_TREE (grig_file_menu), */ - /* GNOMEUIINFO_SUBTREE (N_("_Settings"), grig_settings_menu), */ - /* GNOMEUIINFO_MENU_HELP_TREE (grig_help_menu), */ - /* GNOMEUIINFO_END */ - /* }; */ ! /** \brief Open rotator control window. ! * \param widget The widget which received the signal. ! * \param data User data (NULL). ! * ! * This function calls the function which initializes and starts the ! * rotator related services (daemon, GUI, etc.). It is designed as a ! * callback function to be directly callable from the menubar, but it ! * does not use the parameters to anything. ! */ ! static void ! grig_menu_rot_open (GtkWidget *widget, gpointer data) ! { } /** \brief Exit application. * \param widget The widget which received the signal. --- 42,161 ---- extern GtkWidget *grigapp; /* defined in main.c */ ! extern gint debug; /* defined in main.c */ /* private function prototypes */ static void grig_menu_app_exit (GtkWidget *, gpointer); ! static void grig_menu_set_debug_level (GtkRadioAction *, gpointer); static void grig_menu_config (GtkWidget *, gpointer); + /** \brief Regular menu items. */ + static GtkActionEntry entries[] = { + { "FileMenu", NULL, N_("_Radio") }, + { "SettingsMenu", NULL, N_("_Settings") }, + { "HelpMenu", NULL, N_("_Help") }, ! { "Info", GTK_STOCK_DND, N_("_Info"), "<control>I", N_("Show info about radio"), G_CALLBACK (rig_gui_info_run) }, ! { "Stop", GTK_STOCK_STOP, N_("St_op daemon"), NULL, N_("Stop the Grig daemon"), NULL }, ! { "Start", GTK_STOCK_EXECUTE, N_("St_art daemon"), NULL, N_("Start the Grig daemon"), NULL}, ! { "Exit", GTK_STOCK_QUIT, N_("E_xit"), "<control>Q", N_("Exit the program"), G_CALLBACK (grig_menu_app_exit) }, + { "Debug", NULL, N_("_Debug Level"), NULL, N_("Set Hamlib debug level"), NULL}, + { "About", GTK_STOCK_DIALOG_INFO, N_("_About"), NULL, N_("Shouw about dialog"), G_CALLBACK (grig_about_run) }, + }; + /** \brief Radio items for selectinghamlib debug level. */ + static GtkRadioActionEntry radio_entries[] = { + { "None", NULL, N_("_No Debug"), NULL, N_("Don't show any debug mesages"), 0 }, + { "Bug", NULL, N_("_Bug"), NULL, N_("Show error messages caused by possible bugs"), 1 }, + { "Error", NULL, N_("_Error"), NULL, N_("Show run-time error messages"), 2 }, + { "Warn", NULL, N_("_Warning"), NULL, N_("Show warnings"), 3 }, + { "Verbose", NULL, N_("_Verbose"), NULL, N_("Verbose reporting"), 4 }, + { "Trace", NULL, N_("_Trace"), NULL, N_("Trace everything"), 5 } + }; + /** \brief UI description string. */ + static const char *menu_desc = + "<ui>" + " <menubar name='GrigMenu'>" + " <menu action='FileMenu'>" + " <menuitem action='Info'/>" + " <separator/>" + /*" <menuitem action='Start'/>" + " <menuitem action='Stop'/>" + " <separator/>"*/ + " <menuitem action='Exit'/>" + " </menu>" + " <menu action='SettingsMenu'>" + " <menu action='Debug'>" + " <menuitem action='None'/>" + " <separator/>" + " <menuitem action='Bug'/>" + " <menuitem action='Error'/>" + " <menuitem action='Warn'/>" + " <menuitem action='Verbose'/>" + " <menuitem action='Trace'/>" + " </menu>" + " </menu>" + " <menu action='HelpMenu'>" + " <menuitem action='About'/>" + " </menu>" + " </menubar>" + "</ui>"; ! /** \brief Create Grig menubar. ! * \return The menubar widget. ! * ! * This function creates and initializes the main menubar for grig. ! * It should be called from the main gui_create function. ! */ ! GtkWidget * ! grig_menubar_create () ! { ! GtkWidget *menubar; ! GtkActionGroup *actgrp; ! GtkUIManager *uimgr; ! GtkAccelGroup *accgrp; ! GError *error; + /* create action group */ + actgrp = gtk_action_group_new ("MenuActions"); + gtk_action_group_add_actions (actgrp, entries, G_N_ELEMENTS (entries), NULL); + gtk_action_group_add_radio_actions (actgrp, radio_entries, G_N_ELEMENTS (radio_entries), debug, + G_CALLBACK (grig_menu_set_debug_level), NULL); + /* create UI manager */ + uimgr = gtk_ui_manager_new (); + gtk_ui_manager_insert_action_group (uimgr, actgrp, 0); ! /* accelerator group */ ! accgrp = gtk_ui_manager_get_accel_group (uimgr); ! gtk_window_add_accel_group (GTK_WINDOW (grigapp), accgrp); ! ! /* try to create UI from XML*/ ! error = NULL; ! if (!gtk_ui_manager_add_ui_from_string (uimgr, menu_desc, -1, &error)) { ! g_print (_("Failed to build menubar: %s"), error->message); ! g_error_free (error); ! ! return NULL; ! } ! ! /* now, finally, get the menubar */ ! menubar = gtk_ui_manager_get_widget (uimgr, "/GrigMenu"); + return menubar; } + + /** \brief Exit application. * \param widget The widget which received the signal. *************** *** 155,160 **** /** \brief Set debug level. ! * \param widget The menu item that received the signal. ! * \param level Pointer to an integer representing the debug level. * * This function is called when the user selects a new debug level. --- 176,181 ---- /** \brief Set debug level. ! * \param action The GtkRadioAction item. ! * \param data Pointer to user data (not used). * * This function is called when the user selects a new debug level. *************** *** 163,173 **** */ static void ! grig_menu_set_debug_level (GtkWidget *widget, gpointer level) { ! rig_set_debug (GPOINTER_TO_UINT (level)); ! /* gconf_client_set_int (confclient, GRIG_CONFIG_DEBUG_KEY, */ ! /* GPOINTER_TO_UINT (level), */ ! /* NULL); */ ! /* gconf_client_suggest_sync (confclient, NULL); */ } --- 184,190 ---- */ static void ! grig_menu_set_debug_level (GtkRadioAction *action, gpointer data) { ! rig_set_debug (gtk_radio_action_get_current_value (action)); } *************** *** 188,202 **** - /** \brief Show about box. - * \param widget The menu item that received the signal. - * \param data User data (NULL). - * - * This function is called when the user selects the about menu item - * in the menu bar. It executes the about box component. - */ - static void - grig_menu_about (GtkWidget *widget, gpointer data) - { - grig_about_run (); - } - --- 205,206 ---- Index: grig-menubar.h =================================================================== RCS file: /cvsroot/groundstation/grig2/src/grig-menubar.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** grig-menubar.h 6 Oct 2004 14:05:09 -0000 1.1 --- grig-menubar.h 22 Oct 2004 15:38:09 -0000 1.2 *************** *** 34,36 **** --- 34,39 ---- + GtkWidget *grig_menubar_create (void); + + #endif |