diff options
author | Christian Persch <chpe@cvs.gnome.org> | 2004-02-13 22:13:43 +0800 |
---|---|---|
committer | Christian Persch <chpe@src.gnome.org> | 2004-02-13 22:13:43 +0800 |
commit | 235a1554235f221652529e2d4458730fbf709287 (patch) | |
tree | 76ffd773616401b84ca6224ce288cdf3ddc2669a /src | |
parent | 5d29d085c08e3d7cf6e4557657fe45ee0ad303cb (diff) | |
download | gsoc2013-epiphany-235a1554235f221652529e2d4458730fbf709287.tar gsoc2013-epiphany-235a1554235f221652529e2d4458730fbf709287.tar.gz gsoc2013-epiphany-235a1554235f221652529e2d4458730fbf709287.tar.bz2 gsoc2013-epiphany-235a1554235f221652529e2d4458730fbf709287.tar.lz gsoc2013-epiphany-235a1554235f221652529e2d4458730fbf709287.tar.xz gsoc2013-epiphany-235a1554235f221652529e2d4458730fbf709287.tar.zst gsoc2013-epiphany-235a1554235f221652529e2d4458730fbf709287.zip |
Install the statusbar .h file.
2004-02-13 Christian Persch <chpe@cvs.gnome.org>
* doc/reference/Makefile.am:
* src/Makefile.am:
Install the statusbar .h file.
R src/statusbar.[ch]:
A src/ephy-statusbar.[ch]:
s/statusbar/ephy-statusbar/ and friends.
* src/ephy-window.c: (sync_tab_load_progress), (sync_tab_security),
(ephy_window_init):
Change references from statusbar to ephy-statusbar.
Remove selection-received stuff, since it now lives in EphyTab.
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 4 | ||||
-rwxr-xr-x | src/ephy-statusbar.c | 192 | ||||
-rw-r--r-- | src/ephy-statusbar.h (renamed from src/statusbar.h) | 45 | ||||
-rw-r--r-- | src/ephy-window.c | 43 | ||||
-rwxr-xr-x | src/statusbar.c | 195 |
5 files changed, 232 insertions, 247 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 8c45f2fb4..b4df30330 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -71,7 +71,6 @@ NOINST_H_FILES = \ popup-commands.h \ prefs-dialog.h \ ppview-toolbar.h \ - statusbar.h \ toolbar.h \ window-commands.h @@ -80,6 +79,7 @@ INST_H_FILES = \ ephy-notebook.h \ ephy-session.h \ ephy-shell.h \ + ephy-statusbar.h \ ephy-tab.h \ ephy-window.h @@ -102,6 +102,7 @@ libephymain_la_SOURCES = \ ephy-notebook.c \ ephy-session.c \ ephy-shell.c \ + ephy-statusbar.c \ ephy-tab.c \ ephy-tab.h \ ephy-tabs-menu.c \ @@ -112,7 +113,6 @@ libephymain_la_SOURCES = \ popup-commands.c \ prefs-dialog.c \ ppview-toolbar.c \ - statusbar.c \ toolbar.c \ window-commands.c \ $(INST_H_FILES) \ diff --git a/src/ephy-statusbar.c b/src/ephy-statusbar.c new file mode 100755 index 000000000..016ac5044 --- /dev/null +++ b/src/ephy-statusbar.c @@ -0,0 +1,192 @@ +/* + * Copyright (C) 2002 Jorn Baayen + * Copyright (C) 2003, 2004 Marco Pesenti Gritti + * Copyright (C) 2004 Christian Persch + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * $Id$ + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "ephy-statusbar.h" +#include "ephy-stock-icons.h" +#include "ephy-string.h" + +#include <string.h> +#include <gtk/gtkprogressbar.h> +#include <gtk/gtkeventbox.h> +#include <gtk/gtkimage.h> +#include <gtk/gtkframe.h> +#include <gtk/gtktooltips.h> + +static void ephy_statusbar_class_init (EphyStatusbarClass *klass); +static void ephy_statusbar_init (EphyStatusbar *t); +static void ephy_statusbar_finalize (GObject *object); + +static GObjectClass *parent_class = NULL; + +#define EPHY_STATUSBAR_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_STATUSBAR, EphyStatusbarPrivate)) + +struct EphyStatusbarPrivate +{ + GtkWidget *security_icon; + GtkWidget *progressbar; + GtkTooltips *tooltips; + GtkWidget *security_evbox; +}; + +GType +ephy_statusbar_get_type (void) +{ + static GType type = 0; + + if (type == 0) + { + static const GTypeInfo our_info = + { + sizeof (EphyStatusbarClass), + NULL, /* base_init */ + NULL, /* base_finalize */ + (GClassInitFunc) ephy_statusbar_class_init, + NULL, + NULL, /* class_data */ + sizeof (EphyStatusbar), + 0, /* n_preallocs */ + (GInstanceInitFunc) ephy_statusbar_init + }; + + type = g_type_register_static (GTK_TYPE_STATUSBAR, + "EphyStatusbar", + &our_info, 0); + } + + return type; +} + +static void +ephy_statusbar_class_init (EphyStatusbarClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + parent_class = g_type_class_peek_parent (klass); + + object_class->finalize = ephy_statusbar_finalize; + + g_type_class_add_private (object_class, sizeof (EphyStatusbarPrivate)); +} + +static void +create_statusbar_security_icon (EphyStatusbar *s) +{ + s->security_frame = gtk_frame_new (NULL); + gtk_frame_set_shadow_type (GTK_FRAME (s->security_frame), + GTK_SHADOW_IN); + + s->priv->security_icon = gtk_image_new (); + s->priv->security_evbox = gtk_event_box_new (); + gtk_event_box_set_visible_window (GTK_EVENT_BOX (s->priv->security_evbox), + FALSE); + gtk_container_add (GTK_CONTAINER (s->security_frame), + GTK_WIDGET (s->priv->security_evbox)); + gtk_container_add (GTK_CONTAINER (s->priv->security_evbox), + GTK_WIDGET (s->priv->security_icon)); + + ephy_statusbar_set_security_state (s, FALSE, NULL); + + gtk_widget_show_all (s->security_frame); + + gtk_box_pack_start (GTK_BOX (s), + GTK_WIDGET (s->security_frame), + FALSE, TRUE, 0); +} + +static void +create_statusbar_progress (EphyStatusbar *s) +{ + s->priv->progressbar = gtk_progress_bar_new (); + gtk_widget_show_all (s->priv->progressbar); + + gtk_box_pack_start (GTK_BOX (s), + GTK_WIDGET (s->priv->progressbar), + FALSE, TRUE, 0); +} + +static void +ephy_statusbar_init (EphyStatusbar *t) +{ + t->priv = EPHY_STATUSBAR_GET_PRIVATE (t); + + t->priv->tooltips = gtk_tooltips_new (); + g_object_ref (G_OBJECT (t->priv->tooltips)); + gtk_object_sink (GTK_OBJECT (t->priv->tooltips)); + + gtk_statusbar_set_has_resize_grip (GTK_STATUSBAR (t), FALSE); + + create_statusbar_progress (t); + create_statusbar_security_icon (t); +} + +static void +ephy_statusbar_finalize (GObject *object) +{ + EphyStatusbar *t = EPHY_STATUSBAR (object); + + g_object_unref (t->priv->tooltips); + + G_OBJECT_CLASS (parent_class)->finalize (object); +} + +GtkWidget * +ephy_statusbar_new (void) +{ + return GTK_WIDGET (g_object_new (EPHY_TYPE_STATUSBAR, NULL)); +} + +void +ephy_statusbar_set_security_state (EphyStatusbar *t, + gboolean secure, + const char *tooltip) +{ + const char *stock; + + stock = secure ? EPHY_STOCK_SECURE : EPHY_STOCK_UNSECURE; + + gtk_image_set_from_stock (GTK_IMAGE (t->priv->security_icon), stock, + GTK_ICON_SIZE_MENU); + + gtk_tooltips_set_tip (t->priv->tooltips, t->priv->security_evbox, + tooltip, NULL); +} + +void +ephy_statusbar_set_progress (EphyStatusbar *t, + int progress) +{ + if (progress == -1) + { + gtk_progress_bar_pulse (GTK_PROGRESS_BAR(t->priv->progressbar)); + } + else + { + float fraction; + fraction = (float)(progress) / 100; + gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR(t->priv->progressbar), + fraction); + } +} diff --git a/src/statusbar.h b/src/ephy-statusbar.h index 38f063b6f..de382fd05 100644 --- a/src/statusbar.h +++ b/src/ephy-statusbar.h @@ -1,5 +1,7 @@ /* * Copyright (C) 2002 Jorn Baayen + * Copyright (C) 2003, 2004 Marco Pesenti Gritti + * Copyright (C) 2004 Christian Persch * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,49 +16,54 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * $Id$ */ -#ifndef STATUSBAR_H -#define STATUSBAR_H +#ifndef EPHY_STATUSBAR_H +#define EPHY_STATUSBAR_H #include <gtk/gtkstatusbar.h> G_BEGIN_DECLS -#define EPHY_TYPE_STATUSBAR (statusbar_get_type ()) -#define EPHY_STATUSBAR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EPHY_TYPE_STATUSBAR, Statusbar)) -#define EPHY_STATUSBAR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), EPHY_TYPE_STATUSBAR, StatusbarClass)) +#define EPHY_TYPE_STATUSBAR (ephy_statusbar_get_type ()) +#define EPHY_STATUSBAR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EPHY_TYPE_STATUSBAR, EphyStatusbar)) +#define EPHY_STATUSBAR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), EPHY_TYPE_STATUSBAR, EphyStatusbarClass)) #define EPHY_IS_STATUSBAR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EPHY_TYPE_STATUSBAR)) #define EPHY_IS_STATUSBAR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EPHY_TYPE_STATUSBAR)) -#define EPHY_STATUSBAR_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EPHY_TYPE_STATUSBAR, StatusbarClass)) +#define EPHY_STATUSBAR_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EPHY_TYPE_STATUSBAR, EphyStatusbarClass)) -typedef struct Statusbar Statusbar; -typedef struct StatusbarClass StatusbarClass; -typedef struct StatusbarPrivate StatusbarPrivate; +typedef struct EphyStatusbar EphyStatusbar; +typedef struct EphyStatusbarPrivate EphyStatusbarPrivate; +typedef struct EphyStatusbarClass EphyStatusbarClass; -struct Statusbar +struct EphyStatusbar { GtkStatusbar parent; + /*< public >*/ + GtkWidget *security_frame; + /*< private >*/ - StatusbarPrivate *priv; + EphyStatusbarPrivate *priv; }; -struct StatusbarClass +struct EphyStatusbarClass { GtkStatusbarClass parent_class; }; -GType statusbar_get_type (void); +GType ephy_statusbar_get_type (void); -GtkWidget *statusbar_new (void); +GtkWidget *ephy_statusbar_new (void); -void statusbar_set_security_state (Statusbar *s, - gboolean state, - const char *tooltip); +void ephy_statusbar_set_security_state (EphyStatusbar *statusbar, + gboolean secure, + const char *tooltip); -void statusbar_set_progress (Statusbar *s, - int progress); +void ephy_statusbar_set_progress (EphyStatusbar *statusbar, + int progress); G_END_DECLS diff --git a/src/ephy-window.c b/src/ephy-window.c index f50b4c9d8..193858355 100644 --- a/src/ephy-window.c +++ b/src/ephy-window.c @@ -39,7 +39,7 @@ #include "ephy-zoom.h" #include "ephy-debug.h" #include "ephy-file-helpers.h" -#include "statusbar.h" +#include "ephy-statusbar.h" #include "toolbar.h" #include "popup-commands.h" #include "ephy-encoding-menu.h" @@ -410,21 +410,6 @@ ephy_window_destroy (GtkObject *gtkobject) } static void -ephy_window_selection_received_cb (GtkWidget *widget, - GtkSelectionData *selection_data, - guint time, EphyWindow *window) -{ - EphyTab *tab; - - if (selection_data->length <= 0 || selection_data->data == NULL) - return; - - tab = ephy_window_get_active_tab (window); - - ephy_embed_load_url (ephy_tab_get_embed (tab), selection_data->data); -} - -static void add_widget (GtkUIManager *merge, GtkWidget *widget, EphyWindow *window) { gtk_box_pack_start (GTK_BOX (window->priv->menu_dock), @@ -1049,8 +1034,8 @@ sync_tab_load_progress (EphyTab *tab, GParamSpec *pspec, EphyWindow *window) { if (window->priv->closing) return; - statusbar_set_progress (EPHY_STATUSBAR (window->priv->statusbar), - ephy_tab_get_load_percent (tab)); + ephy_statusbar_set_progress (EPHY_STATUSBAR (window->priv->statusbar), + ephy_tab_get_load_percent (tab)); } static void @@ -1181,8 +1166,8 @@ sync_tab_security (EphyTab *tab, GParamSpec *pspec, EphyWindow *window) } - statusbar_set_security_state (EPHY_STATUSBAR (window->priv->statusbar), - secure, tooltip); + ephy_statusbar_set_security_state (EPHY_STATUSBAR (window->priv->statusbar), + secure, tooltip); g_free (tooltip); } @@ -1923,18 +1908,12 @@ ephy_window_init (EphyWindow *window) /* Setup the UI manager and connect verbs */ setup_ui_manager (window); - window->priv->toolbar = toolbar_new (window); - gtk_box_pack_end (GTK_BOX (window->priv->menu_dock), - GTK_WIDGET (window->priv->toolbar), - FALSE, FALSE, 0); - - window->priv->notebook = setup_notebook (window); gtk_box_pack_start (GTK_BOX (window->priv->main_vbox), GTK_WIDGET (window->priv->notebook), TRUE, TRUE, 0); - window->priv->statusbar = statusbar_new (); + window->priv->statusbar = ephy_statusbar_new (); gtk_box_pack_start (GTK_BOX (window->priv->main_vbox), GTK_WIDGET (window->priv->statusbar), FALSE, TRUE, 0); @@ -1950,6 +1929,12 @@ ephy_window_init (EphyWindow *window) window->priv->enc_menu = ephy_encoding_menu_new (window); window->priv->bmk_menu = ephy_bookmarks_menu_new (window); + /* create the toolbar */ + window->priv->toolbar = toolbar_new (window); + gtk_box_pack_end (GTK_BOX (window->priv->menu_dock), + GTK_WIDGET (window->priv->toolbar), + FALSE, FALSE, 0); + /* Once the window is sufficiently created let the extensions attach to it */ manager = EPHY_EXTENSION (ephy_shell_get_extensions_manager (ephy_shell)); ephy_extension_attach_window (manager, window); @@ -1959,10 +1944,6 @@ ephy_window_init (EphyWindow *window) gtk_widget_show (GTK_WIDGET (window->priv->notebook)); gtk_widget_show (window->priv->statusbar); - g_signal_connect (window, - "selection-received", - G_CALLBACK (ephy_window_selection_received_cb), - window); g_signal_connect (window, "window-state-event", G_CALLBACK (ephy_window_state_event_cb), window); diff --git a/src/statusbar.c b/src/statusbar.c deleted file mode 100755 index 22054b622..000000000 --- a/src/statusbar.c +++ /dev/null @@ -1,195 +0,0 @@ -/* - * Copyright (C) 2002 Jorn Baayen - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * $Id$ - */ - -#include "statusbar.h" -#include "ephy-stock-icons.h" -#include "ephy-string.h" - -#include <string.h> -#include <time.h> -#include <gtk/gtkprogressbar.h> -#include <gtk/gtkeventbox.h> -#include <gtk/gtkimage.h> -#include <gtk/gtkframe.h> -#include <gtk/gtktooltips.h> - -static void statusbar_class_init (StatusbarClass *klass); -static void statusbar_init (Statusbar *t); -static void statusbar_finalize (GObject *object); - -static GObjectClass *parent_class = NULL; - -#define EPHY_STATUSBAR_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_STATUSBAR, StatusbarPrivate)) - -struct StatusbarPrivate -{ - GtkWidget *security_icon; - GtkWidget *progress; - GtkTooltips *tooltips; - GtkWidget *security_evbox; -}; - -GType -statusbar_get_type (void) -{ - static GType statusbar_type = 0; - - if (statusbar_type == 0) - { - static const GTypeInfo our_info = - { - sizeof (StatusbarClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) statusbar_class_init, - NULL, - NULL, /* class_data */ - sizeof (Statusbar), - 0, /* n_preallocs */ - (GInstanceInitFunc) statusbar_init - }; - - statusbar_type = g_type_register_static (GTK_TYPE_STATUSBAR, - "Statusbar", - &our_info, 0); - } - - return statusbar_type; - -} - -static void -statusbar_class_init (StatusbarClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - parent_class = g_type_class_peek_parent (klass); - - object_class->finalize = statusbar_finalize; - - g_type_class_add_private (object_class, sizeof(StatusbarPrivate)); -} - -static void -create_statusbar_security_icon (Statusbar *s) -{ - GtkWidget *security_frame; - - security_frame = gtk_frame_new (NULL); - gtk_frame_set_shadow_type (GTK_FRAME (security_frame), - GTK_SHADOW_IN); - - s->priv->security_icon = gtk_image_new (); - s->priv->security_evbox = gtk_event_box_new (); - gtk_event_box_set_visible_window (GTK_EVENT_BOX (s->priv->security_evbox), - FALSE); - gtk_container_add (GTK_CONTAINER (security_frame), - GTK_WIDGET (s->priv->security_evbox)); - gtk_container_add (GTK_CONTAINER (s->priv->security_evbox), - GTK_WIDGET (s->priv->security_icon)); - - statusbar_set_security_state (s, FALSE, NULL); - - gtk_widget_show_all (security_frame); - - gtk_box_pack_start (GTK_BOX (s), - GTK_WIDGET (security_frame), - FALSE, TRUE, 0); -} - -static void -create_statusbar_progress (Statusbar *s) -{ - s->priv->progress = gtk_progress_bar_new (); - gtk_widget_show_all (s->priv->progress); - - gtk_box_pack_start (GTK_BOX (s), - GTK_WIDGET (s->priv->progress), - FALSE, TRUE, 0); -} - -static void -statusbar_init (Statusbar *t) -{ - t->priv = EPHY_STATUSBAR_GET_PRIVATE (t); - - t->priv->tooltips = gtk_tooltips_new (); - g_object_ref (G_OBJECT (t->priv->tooltips)); - gtk_object_sink (GTK_OBJECT (t->priv->tooltips)); - - gtk_statusbar_set_has_resize_grip (GTK_STATUSBAR (t), FALSE); - - create_statusbar_progress (t); - create_statusbar_security_icon (t); -} - -static void -statusbar_finalize (GObject *object) -{ - Statusbar *t = EPHY_STATUSBAR (object); - - g_object_unref (t->priv->tooltips); - - G_OBJECT_CLASS (parent_class)->finalize (object); -} - -GtkWidget * -statusbar_new (void) -{ - GtkWidget *t; - - t = GTK_WIDGET (g_object_new (EPHY_TYPE_STATUSBAR, - NULL)); - - return t; -} - -void -statusbar_set_security_state (Statusbar *t, - gboolean state, - const char *tooltip) -{ - const char *stock; - - stock = state ? EPHY_STOCK_SECURE : EPHY_STOCK_UNSECURE; - - gtk_image_set_from_stock (GTK_IMAGE (t->priv->security_icon), stock, - GTK_ICON_SIZE_MENU); - - gtk_tooltips_set_tip (t->priv->tooltips, t->priv->security_evbox, - tooltip, NULL); -} - -void -statusbar_set_progress (Statusbar *t, - int progress) -{ - if (progress == -1) - { - gtk_progress_bar_pulse (GTK_PROGRESS_BAR(t->priv->progress)); - } - else - { - float tmp; - tmp = (float)(progress) / 100; - gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR(t->priv->progress), - tmp); - } -} |