From 016bd5d0c97aacf3e5540ff0d794e08b8a76072a Mon Sep 17 00:00:00 2001 From: Jim Evins Date: Mon, 7 Oct 2002 04:45:12 +0000 Subject: [PATCH] Initial status bar code -- only the zoom_info area implemented. git-svn-id: https://glabels.svn.sourceforge.net/svnroot/glabels/trunk@149 f5e0f49d-192f-0410-a22d-a8d8700d0965 --- glabels2/src/glabels-ui.xml | 10 +++- glabels2/src/ui.c | 91 ++++++++++++++++++++++-------------- glabels2/src/ui.h | 28 ++++++----- glabels2/src/view.c | 33 +++++++------ glabels2/src/view.h | 92 +++++++++++++++++++++++-------------- glabels2/src/window.c | 77 +++++++++++++++++++++++++++---- glabels2/src/window.h | 5 ++ 7 files changed, 229 insertions(+), 107 deletions(-) diff --git a/glabels2/src/glabels-ui.xml b/glabels2/src/glabels-ui.xml index b1220a7d..7f4d2b2f 100644 --- a/glabels2/src/glabels-ui.xml +++ b/glabels2/src/glabels-ui.xml @@ -141,10 +141,10 @@ - - @@ -342,5 +342,11 @@ + + + + + + diff --git a/glabels2/src/ui.c b/glabels2/src/ui.c index 8280b357..fe29ad71 100644 --- a/glabels2/src/ui.c +++ b/glabels2/src/ui.c @@ -33,19 +33,19 @@ #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); @@ -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, diff --git a/glabels2/src/ui.h b/glabels2/src/ui.h index aa8e3723..83fdd6c2 100644 --- a/glabels2/src/ui.h +++ b/glabels2/src/ui.h @@ -28,21 +28,27 @@ #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__ */ diff --git a/glabels2/src/view.c b/glabels2/src/view.c index a3eb8e83..ee571cdd 100644 --- a/glabels2/src/view.c +++ b/glabels2/src/view.c @@ -42,16 +42,17 @@ #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), diff --git a/glabels2/src/view.h b/glabels2/src/view.h index 4ad4a094..2d100254 100644 --- a/glabels2/src/view.h +++ b/glabels2/src/view.h @@ -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 diff --git a/glabels2/src/window.c b/glabels2/src/window.c index e114d944..35c25332 100644 --- a/glabels2/src/window.c +++ b/glabels2/src/window.c @@ -29,24 +29,27 @@ #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. */ /*---------------------------------------------------------------------------*/ diff --git a/glabels2/src/window.h b/glabels2/src/window.h index d8032b52..523f2664 100644 --- a/glabels2/src/window.h +++ b/glabels2/src/window.h @@ -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 { -- 2.39.5