]> git.sur5r.net Git - glabels/commitdiff
Initial status bar code -- only the zoom_info area implemented.
authorJim Evins <evins@snaught.com>
Mon, 7 Oct 2002 04:45:12 +0000 (04:45 +0000)
committerJim Evins <evins@snaught.com>
Mon, 7 Oct 2002 04:45:12 +0000 (04:45 +0000)
git-svn-id: https://glabels.svn.sourceforge.net/svnroot/glabels/trunk@149 f5e0f49d-192f-0410-a22d-a8d8700d0965

glabels2/src/glabels-ui.xml
glabels2/src/ui.c
glabels2/src/ui.h
glabels2/src/view.c
glabels2/src/view.h
glabels2/src/window.c
glabels2/src/window.h

index b1220a7dd11126caa4ffa1376981de8ffbd71bf0..7f4d2b2f631170ee562c344da4c220cd30ec62b8 100644 (file)
        <cmd name="ToolsLowerObjects"
             _tip="Lower object to bottom"/>
        
-       <cmd name="HelpContents" _label="Contents" _tip="Open the gedit manual"
+       <cmd name="HelpContents" _label="Contents" _tip="Open the glabels manual"
        accel="F1" pixtype="stock" pixname="gtk-help"/>
 
-        <cmd name="About" _label="About..." _tip="About this application"
+        <cmd name="About" _label="About..." _tip="About glabels"
         pixtype="stock" pixname="About"/>
 
 
 
 </dockitem>
 
+<status resize_grip="1">
+       <item name="main"/>
+       <control name="Zoom"/>
+       <control name="Cursor"/>
+</status>
+
 </Root>
 
index 8280b3571623edd9cffd9a9a2daaed6215487126..fe29ad7172fde9250e7c5971d3a40651f495c112 100644 (file)
 
 #include "debug.h"
 
-/*========================================================*/
-/* Private macros and constants.                          */
-/*========================================================*/
+/*=======================================================================================*/
+/* Private macros and constants.                                                         */
+/*=======================================================================================*/
 #define GLABELS_UI_XML GLABELS_UI_DIR "glabels-ui.xml"
 
-/*========================================================*/
-/* Private types.                                         */
-/*========================================================*/
+/*=======================================================================================*/
+/* Private types.                                                                        */
+/*=======================================================================================*/
 
 
-/*===========================================*/
-/* Private globals                           */
-/*===========================================*/
+/*=======================================================================================*/
+/* Private globals                                                                       */
+/*=======================================================================================*/
 
 static BonoboUIVerb gl_ui_verbs [] = {
        BONOBO_UI_VERB ("FileNew", gl_cmd_file_new),
@@ -139,32 +139,31 @@ static gchar* atomic_selection_verbs [] = {
 };
 
 
-/*===========================================*/
-/* Local function prototypes                 */
-/*===========================================*/
+/*=======================================================================================*/
+/* Local function prototypes                                                             */
+/*=======================================================================================*/
 
-static void view_menu_item_toggled_cb (
-                       BonoboUIComponent           *ui_component,
-                       const char                  *path,
-                       Bonobo_UIComponent_EventType type,
-                       const char                  *state,
-                       BonoboWindow                *win);
+static void view_menu_item_toggled_cb     (BonoboUIComponent           *ui_component,
+                                          const char                  *path,
+                                          Bonobo_UIComponent_EventType type,
+                                          const char                  *state,
+                                          BonoboWindow                *win);
 
-static void set_app_main_toolbar_style           (BonoboUIComponent *ui_component);
-static void set_app_drawing_toolbar_style (BonoboUIComponent *ui_component);
+static void set_app_main_toolbar_style           (BonoboUIComponent           *ui_component);
 
-static void
-set_verb_sensitive (BonoboUIComponent  *ui_component,
-                   gchar              *cname,
-                   gboolean            sensitive);
-static void
-set_verb_list_sensitive (BonoboUIComponent   *ui_component,
-                        gchar              **vlist,
-                        gboolean             sensitive);
-static void
-set_verb_state (BonoboUIComponent   *ui_component,
-               gchar               *cname,
-               gboolean             state);
+static void set_app_drawing_toolbar_style (BonoboUIComponent           *ui_component);
+
+static void set_verb_sensitive            (BonoboUIComponent           *ui_component,
+                                          gchar                       *cname,
+                                          gboolean                     sensitive);
+
+static void set_verb_list_sensitive       (BonoboUIComponent           *ui_component,
+                                          gchar                      **vlist,
+                                          gboolean                     sensitive);
+
+static void set_verb_state                (BonoboUIComponent           *ui_component,
+                                          gchar                       *cname,
+                                          gboolean                     state);
 
 
 \f
@@ -173,10 +172,13 @@ set_verb_state (BonoboUIComponent   *ui_component,
 /*****************************************************************************/
 void
 gl_ui_init (BonoboUIComponent *ui_component,
-           BonoboWindow      *win)
+           BonoboWindow      *win,
+           GtkWidget         *cursor_info_frame,
+           GtkWidget         *zoom_info_frame)
 {
-        GnomeRecentView *recent_view;
+        GnomeRecentView  *recent_view;
         GnomeRecentModel *recent_model;
+       BonoboControl    *control;
 
        gl_debug (DEBUG_UI, "START");
 
@@ -241,7 +243,26 @@ gl_ui_init (BonoboUIComponent *ui_component,
 
        set_verb_list_sensitive (ui_component, doc_verbs, FALSE);
 
-        /* add a GeditRecentView object */
+       /* Status bar */
+        bonobo_ui_component_set_prop (ui_component,
+                                     "/status", "hidden", "0", NULL);
+
+       control = bonobo_control_new (cursor_info_frame);
+       bonobo_ui_component_object_set (ui_component,
+                                       "/status/Cursor", BONOBO_OBJREF (control), NULL);
+       bonobo_object_unref (BONOBO_OBJECT (control));
+        bonobo_ui_component_set_prop (ui_component,
+                                     "/status/Cursor", "hidden", "0", NULL);
+
+       control = bonobo_control_new (zoom_info_frame);
+       bonobo_ui_component_object_set (ui_component,
+                                       "/status/Zoom", BONOBO_OBJREF (control), NULL);
+       bonobo_object_unref (BONOBO_OBJECT (control));
+        bonobo_ui_component_set_prop (ui_component,
+                                     "/status/Zoom", "hidden", "0", NULL);
+
+
+       /* add a GeditRecentView object */
         recent_model = gl_recent_get_model ();
         recent_view  =
                GNOME_RECENT_VIEW (gnome_recent_view_bonobo_new (ui_component,
index aa8e3723d9ad283f2789658359ed121c58107d89..83fdd6c2490f96852227fdfc6d1c82101c07a097 100644 (file)
 
 #include "view.h"
 
-extern void gl_ui_init                   (BonoboUIComponent *ui_component,
-                                         BonoboWindow      *win);
+G_BEGIN_DECLS
 
-extern void gl_ui_update_all             (BonoboUIComponent *ui_component,
-                                         glView            *view);
+void gl_ui_init                   (BonoboUIComponent *ui_component,
+                                  BonoboWindow      *win,
+                                  GtkWidget         *cursor_info_frame,
+                                  GtkWidget         *zoom_info_frame);
 
-extern void gl_ui_update_nodoc           (BonoboUIComponent *ui_component);
+void gl_ui_update_all             (BonoboUIComponent *ui_component,
+                                  glView            *view);
 
-extern void gl_ui_update_modified_verbs  (BonoboUIComponent *ui_component,
-                                         glLabel           *label);
+void gl_ui_update_nodoc           (BonoboUIComponent *ui_component);
 
-extern void gl_ui_update_selection_verbs (BonoboUIComponent *ui_component,
-                                         glView            *view);
+void gl_ui_update_modified_verbs  (BonoboUIComponent *ui_component,
+                                  glLabel           *label);
 
-extern void gl_ui_update_undo_redo_verbs (BonoboUIComponent *ui_component,
-                                         glLabel           *label);
+void gl_ui_update_selection_verbs (BonoboUIComponent *ui_component,
+                                  glView            *view);
+
+void gl_ui_update_undo_redo_verbs (BonoboUIComponent *ui_component,
+                                  glLabel           *label);
+
+G_END_DECLS
 
 #endif /* __GL_UI_H__ */
index a3eb8e83ae0050e49a3d41bbc60ba41204ffdb77..ee571cdd5f52c049230a5e9699c0641083875655 100644 (file)
 
 #include "debug.h"
 
-/*========================================================*/
-/* Private macros and constants.                          */
-/*========================================================*/
+/*==========================================================================*/
+/* Private macros and constants.                                            */
+/*==========================================================================*/
 
 #define SEL_LINE_COLOR  GL_COLOR_A (0, 0, 255, 128)
 #define SEL_FILL_COLOR  GL_COLOR_A (192, 192, 255, 128)
 
-/*========================================================*/
-/* Private types.                                         */
-/*========================================================*/
+
+/*==========================================================================*/
+/* Private types.                                                           */
+/*==========================================================================*/
 
 enum {
        SELECTION_CHANGED,
@@ -61,9 +62,10 @@ enum {
        LAST_SIGNAL
 };
 
-/*===========================================*/
-/* Private globals                           */
-/*===========================================*/
+
+/*==========================================================================*/
+/* Private globals                                                          */
+/*==========================================================================*/
 
 static GtkContainerClass *parent_class;
 
@@ -80,9 +82,10 @@ static gdouble scales[] = {
        0.0
 };
 
-/*===========================================*/
-/* Local function prototypes                 */
-/*===========================================*/
+
+/*==========================================================================*/
+/* Local function prototypes                                                */
+/*==========================================================================*/
 
 static void       gl_view_class_init              (glViewClass *class);
 static void       gl_view_init                    (glView *view);
@@ -235,9 +238,9 @@ gl_view_class_init (glViewClass *class)
                              G_SIGNAL_RUN_LAST,
                              G_STRUCT_OFFSET (glViewClass, mode_changed),
                              NULL, NULL,
-                             gl_marshal_VOID__STRING,
+                             gl_marshal_VOID__VOID,
                              G_TYPE_NONE,
-                             1, G_TYPE_STRING);
+                             0);
 
        gl_debug (DEBUG_VIEW, "END");
 }
@@ -1852,7 +1855,7 @@ canvas_event_arrow_mode (GnomeCanvas *canvas,
                gnome_canvas_window_to_world (canvas,
                                              event->motion.x,
                                              event->motion.y, &x, &y);
-               g_signal_emit (G_OBJECT(view), signals[ZOOM_CHANGED], 0, x, y);
+               g_signal_emit (G_OBJECT(view), signals[POINTER_MOVED], 0, x, y);
                if (dragging && (event->motion.state & GDK_BUTTON1_MASK)) {
                        gnome_canvas_item_set (item,
                                               "x1", MIN (x, x0),
index 4ad4a09439db4df3ebafb75a1ed3d10fa44f4f3a..2d10025455455884b546b886017b8cf0d3883118 100644 (file)
@@ -82,50 +82,74 @@ struct _glViewClass {
        void (*pointer_moved)     (glView *view,
                                   gdouble x, gdouble y, gpointer user_data);
        void (*mode_changed)      (glView *view,
-                                  gchar *modeline, gpointer user_data);
+                                  gpointer user_data);
 };
 
-extern guint     gl_view_get_type           (void);
+G_BEGIN_DECLS
 
-extern GtkWidget *gl_view_new               (glLabel *label);
+guint     gl_view_get_type           (void);
 
-extern void      gl_view_raise_fg           (glView *view);
+GtkWidget *gl_view_new               (glLabel           *label);
 
-extern void      gl_view_arrow_mode         (glView *view);
-extern void      gl_view_object_create_mode (glView *view,
-                                            glLabelObjectType type);
 
-extern void      gl_view_select_object      (glView *view,
-                                            glViewObject *view_object);
-extern void      gl_view_unselect_object    (glView *view,
-                                            glViewObject *view_object);
-extern void      gl_view_select_all         (glView *view);
-extern void      gl_view_unselect_all       (glView *view);
-extern void      gl_view_select_region      (glView  *view,
-                                            gdouble  x1,
-                                            gdouble  y1,
-                                            gdouble  x2,
-                                            gdouble  y2);
+void      gl_view_raise_fg           (glView            *view);
 
-extern gboolean  gl_view_is_selection_empty (glView *view);
-extern gboolean  gl_view_is_selection_atomic(glView *view);
 
-extern void      gl_view_delete_selection   (glView *view);
-extern void      gl_view_edit_object_props  (glView *view);
-extern void      gl_view_raise_selection    (glView *view);
-extern void      gl_view_lower_selection    (glView *view);
+void      gl_view_arrow_mode         (glView            *view);
 
-extern void      gl_view_cut                (glView *view);
-extern void      gl_view_copy               (glView *view);
-extern void      gl_view_paste              (glView *view);
+void      gl_view_object_create_mode (glView            *view,
+                                     glLabelObjectType  type);
 
-extern void      gl_view_zoom_in            (glView *view);
-extern void      gl_view_zoom_out           (glView *view);
-extern void      gl_view_set_zoom           (glView *view, gdouble scale);
-extern gdouble   gl_view_get_zoom           (glView *view);
 
-extern int       gl_view_item_event_handler (GnomeCanvasItem *item,
-                                            GdkEvent        *event,
-                                            glViewObject    *view_object);
+void      gl_view_select_object      (glView            *view,
+                                     glViewObject      *view_object);
+
+void      gl_view_unselect_object    (glView            *view,
+                                     glViewObject      *view_object);
+
+void      gl_view_select_all         (glView            *view);
+
+void      gl_view_unselect_all       (glView            *view);
+
+void      gl_view_select_region      (glView            *view,
+                                     gdouble            x1,
+                                     gdouble            y1,
+                                     gdouble            x2,
+                                     gdouble            y2);
+
+gboolean  gl_view_is_selection_empty (glView            *view);
+
+gboolean  gl_view_is_selection_atomic(glView            *view);
+
+void      gl_view_delete_selection   (glView            *view);
+
+void      gl_view_edit_object_props  (glView            *view);
+
+void      gl_view_raise_selection    (glView            *view);
+
+void      gl_view_lower_selection    (glView            *view);
+
+void      gl_view_cut                (glView            *view);
+
+void      gl_view_copy               (glView            *view);
+
+void      gl_view_paste              (glView            *view);
+
+
+void      gl_view_zoom_in            (glView            *view);
+
+void      gl_view_zoom_out           (glView            *view);
+
+void      gl_view_set_zoom           (glView            *view,
+                                     gdouble            scale);
+
+gdouble   gl_view_get_zoom           (glView            *view);
+
+
+int       gl_view_item_event_handler (GnomeCanvasItem   *item,
+                                     GdkEvent          *event,
+                                     glViewObject      *view_object);
+
+G_END_DECLS
 
 #endif
index e114d94415ee5b8f04e5b3c519164a8729cf1378..35c2533217ef45383537294cc04255ef4f2787c3 100644 (file)
 
 #include "debug.h"
 
-/*========================================================*/
-/* Private macros and constants.                          */
-/*========================================================*/
+/*============================================================================*/
+/* Private macros and constants.                                              */
+/*============================================================================*/
+
 #define DEFAULT_WINDOW_WIDTH  500
 #define DEFAULT_WINDOW_HEIGHT 375
 
+#define CURSOR_INFO_WIDTH     150
+#define ZOOM_INFO_WIDTH        50
 
-/*===========================================*/
-/* Private globals                           */
-/*===========================================*/
+/*============================================================================*/
+/* Private globals                                                            */
+/*============================================================================*/
 static BonoboWindowClass *parent_class;
 
 static GList *window_list = NULL;
 
 
-/*===========================================*/
-/* Local function prototypes                 */
-/*===========================================*/
+/*============================================================================*/
+/* Local function prototypes                                                  */
+/*============================================================================*/
 
 static void     gl_window_class_init   (glWindowClass *class);
 static void     gl_window_init         (glWindow      *window);
@@ -63,6 +66,10 @@ static gboolean window_delete_event_cb (glWindow      *window,
 static void     selection_changed_cb   (glView        *view,
                                        glWindow      *window);
 
+static void     zoom_changed_cb        (glView   *view,
+                                       gdouble  zoom,
+                                       glWindow *window);
+
 static void     name_changed_cb        (glLabel       *label,
                                        glWindow      *window);
 
@@ -130,7 +137,25 @@ gl_window_init (glWindow *window)
        bonobo_ui_component_set_container (ui_component,
                                           BONOBO_OBJREF (ui_container),
                                           NULL);
-       gl_ui_init (ui_component, BONOBO_WINDOW (window));
+
+       window->cursor_info = gtk_label_new (NULL);
+       gtk_widget_set_size_request (window->cursor_info, CURSOR_INFO_WIDTH, -1);
+       window->cursor_info_frame = gtk_frame_new (NULL);
+       gtk_frame_set_shadow_type (GTK_FRAME(window->cursor_info_frame), GTK_SHADOW_IN);
+       gtk_container_add (GTK_CONTAINER(window->cursor_info_frame), window->cursor_info);
+       gtk_widget_show_all (window->cursor_info_frame);
+
+       window->zoom_info = gtk_label_new (NULL);
+       gtk_widget_set_size_request (window->zoom_info, ZOOM_INFO_WIDTH, -1);
+       window->zoom_info_frame = gtk_frame_new (NULL);
+       gtk_frame_set_shadow_type (GTK_FRAME(window->zoom_info_frame), GTK_SHADOW_IN);
+       gtk_container_add (GTK_CONTAINER(window->zoom_info_frame), window->zoom_info);
+       gtk_widget_show_all (window->zoom_info_frame);
+
+       gl_ui_init (ui_component,
+                   BONOBO_WINDOW (window),
+                   window->cursor_info_frame,
+                   window->zoom_info_frame);
 
        gtk_window_set_default_size (GTK_WINDOW (window),
                                     DEFAULT_WINDOW_WIDTH,
@@ -272,6 +297,8 @@ void
 gl_window_set_label (glWindow    *window,
                     glLabel     *label)
 {
+       gchar *string;
+
        gl_debug (DEBUG_WINDOW, "START");
 
        g_return_if_fail (GL_IS_WINDOW (window));
@@ -293,9 +320,17 @@ gl_window_set_label (glWindow    *window,
 
        gl_ui_update_all (window->uic, GL_VIEW(window->view));
 
+       string = g_strdup_printf ("%3.0f%%",
+                                 100.0*gl_view_get_zoom (GL_VIEW(window->view)));
+       gtk_label_set_text (GTK_LABEL(window->zoom_info), string);
+       g_free (string);
+
        g_signal_connect (G_OBJECT(window->view), "selection_changed",
                          G_CALLBACK(selection_changed_cb), window);
 
+       g_signal_connect (G_OBJECT(window->view), "zoom_changed",
+                         G_CALLBACK(zoom_changed_cb), window);
+
        g_signal_connect (G_OBJECT(label), "name_changed",
                          G_CALLBACK(name_changed_cb), window);
 
@@ -383,6 +418,28 @@ selection_changed_cb (glView   *view,
        gl_debug (DEBUG_WINDOW, "END");
 }
 
+/*---------------------------------------------------------------------------*/
+/* PRIVATE.  View "zoom state changed" callback.                             */
+/*---------------------------------------------------------------------------*/
+static void 
+zoom_changed_cb (glView   *view,
+                gdouble  zoom,
+                glWindow *window)
+{
+       gchar *string;
+
+       gl_debug (DEBUG_WINDOW, "START");
+
+       g_return_if_fail (view && GL_IS_VIEW (view));
+       g_return_if_fail (window && GL_IS_WINDOW (window));
+
+       string = g_strdup_printf ("%3.0f%%", 100.0*zoom);
+       gtk_label_set_text (GTK_LABEL(window->zoom_info), string);
+       g_free (string);
+
+       gl_debug (DEBUG_WINDOW, "END");
+}
+
 /*---------------------------------------------------------------------------*/
 /* PRIVATE.  Label "name changed" callback.                                  */
 /*---------------------------------------------------------------------------*/
index d8032b528c8a769234f4ba44a5bd9accd5749cfa..523f26643b0b259dbe2d463f515716f3f7b0ec66 100644 (file)
@@ -51,6 +51,11 @@ struct _glWindow {
        BonoboUIComponent   *uic;
 
        GtkWidget           *view;
+
+       GtkWidget           *cursor_info;
+       GtkWidget           *cursor_info_frame;
+       GtkWidget           *zoom_info;
+       GtkWidget           *zoom_info_frame;
 };
 
 struct _glWindowClass {