aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/Makefile.am9
-rw-r--r--src/empathy-call-window.c28
-rw-r--r--src/empathy-sidebar.c606
-rw-r--r--src/empathy-sidebar.h85
-rw-r--r--src/ev-sidebar.c338
-rw-r--r--src/ev-sidebar.h76
6 files changed, 434 insertions, 708 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index c77b63a91..378bdee67 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -106,13 +106,16 @@ empathy_debugger_SOURCES = \
empathy-debugger.c \
$(NULL)
-empathy_av_SOURCES = \
+empathy_handwritten_av_source = \
empathy-av.c \
empathy-call-window-fullscreen.c empathy-call-window-fullscreen.h \
empathy-call-window.c empathy-call-window.h \
- empathy-sidebar.c empathy-sidebar.h \
$(NULL)
+empathy_av_SOURCES = \
+ $(empathy_handwritten_av_source) \
+ ev-sidebar.c ev-sidebar.h
+
empathy_auth_client_SOURCES = \
empathy-auth-client.c
@@ -152,7 +155,7 @@ nodist_empathy_SOURCES = $(BUILT_SOURCES)
check_c_sources = \
$(empathy_handwritten_source) \
$(empathy_logs_SOURCES) \
- $(empathy_av_SOURCES)
+ $(empathy_handwritten_av_source)
include $(top_srcdir)/tools/check-coding-style.mk
check-local: check-coding-style
diff --git a/src/empathy-call-window.c b/src/empathy-call-window.c
index bdf2a6b68..5b8db88da 100644
--- a/src/empathy-call-window.c
+++ b/src/empathy-call-window.c
@@ -53,7 +53,7 @@
#include "empathy-call-window.h"
#include "empathy-call-window-fullscreen.h"
-#include "empathy-sidebar.h"
+#include "ev-sidebar.h"
#define BUTTON_ID "empathy-call-dtmf-button-id"
@@ -245,10 +245,10 @@ static void empathy_call_window_set_send_video (EmpathyCallWindow *window,
static void empathy_call_window_mic_toggled_cb (
GtkToggleToolButton *toggle, EmpathyCallWindow *window);
-static void empathy_call_window_sidebar_hidden_cb (EmpathySidebar *sidebar,
+static void empathy_call_window_sidebar_hidden_cb (EvSidebar *sidebar,
EmpathyCallWindow *window);
-static void empathy_call_window_sidebar_shown_cb (EmpathySidebar *sidebar,
+static void empathy_call_window_sidebar_shown_cb (EvSidebar *sidebar,
EmpathyCallWindow *window);
static void empathy_call_window_hangup_cb (gpointer object,
@@ -1183,7 +1183,7 @@ empathy_call_window_init (EmpathyCallWindow *self)
gtk_box_pack_end (GTK_BOX (priv->vbox), h, FALSE, FALSE, 3);
gtk_box_pack_end (GTK_BOX (h), priv->sidebar_button, FALSE, FALSE, 3);
- priv->sidebar = empathy_sidebar_new ();
+ priv->sidebar = ev_sidebar_new ();
g_signal_connect (G_OBJECT (priv->sidebar),
"hide", G_CALLBACK (empathy_call_window_sidebar_hidden_cb), self);
g_signal_connect (G_OBJECT (priv->sidebar),
@@ -1191,21 +1191,21 @@ empathy_call_window_init (EmpathyCallWindow *self)
gtk_paned_pack2 (GTK_PANED (priv->pane), priv->sidebar, FALSE, FALSE);
page = empathy_call_window_create_audio_input (self);
- empathy_sidebar_add_page (EMPATHY_SIDEBAR (priv->sidebar), _("Audio input"),
- page);
+ ev_sidebar_add_page (EV_SIDEBAR (priv->sidebar), "audio-input",
+ _("Audio input"), page);
page = empathy_call_window_create_video_input (self);
- empathy_sidebar_add_page (EMPATHY_SIDEBAR (priv->sidebar), _("Video input"),
- page);
+ ev_sidebar_add_page (EV_SIDEBAR (priv->sidebar), "video-input",
+ _("Video input"), page);
priv->dtmf_panel = empathy_call_window_create_dtmf (self);
- empathy_sidebar_add_page (EMPATHY_SIDEBAR (priv->sidebar), _("Dialpad"),
- priv->dtmf_panel);
+ ev_sidebar_add_page (EV_SIDEBAR (priv->sidebar), "dialpad",
+ _("Dialpad"), priv->dtmf_panel);
gtk_widget_set_sensitive (priv->dtmf_panel, FALSE);
- empathy_sidebar_add_page (EMPATHY_SIDEBAR (priv->sidebar), _("Details"),
- priv->details_vbox);
+ ev_sidebar_add_page (EV_SIDEBAR (priv->sidebar), "details",
+ _("Details"), priv->details_vbox);
gtk_widget_show_all (top_vbox);
@@ -3100,7 +3100,7 @@ empathy_call_window_mic_toggled_cb (GtkToggleToolButton *toggle,
}
static void
-empathy_call_window_sidebar_hidden_cb (EmpathySidebar *sidebar,
+empathy_call_window_sidebar_hidden_cb (EvSidebar *sidebar,
EmpathyCallWindow *window)
{
EmpathyCallWindowPriv *priv = GET_PRIV (window);
@@ -3110,7 +3110,7 @@ empathy_call_window_sidebar_hidden_cb (EmpathySidebar *sidebar,
}
static void
-empathy_call_window_sidebar_shown_cb (EmpathySidebar *sidebar,
+empathy_call_window_sidebar_shown_cb (EvSidebar *sidebar,
EmpathyCallWindow *window)
{
EmpathyCallWindowPriv *priv = GET_PRIV (window);
diff --git a/src/empathy-sidebar.c b/src/empathy-sidebar.c
deleted file mode 100644
index 776e0a81f..000000000
--- a/src/empathy-sidebar.c
+++ /dev/null
@@ -1,606 +0,0 @@
-/*
- * Copyright (C) 2004 Red Hat, Inc.
- * Copyright (C) 2007 The Free Software Foundation
- * Copyright (C) 2008 Marco Barisione <marco@barisione.org>
- *
- * Based on evince code (shell/ev-sidebar.c) by:
- * - Jonathan Blandford <jrb@alum.mit.edu>
- *
- * Base on eog code (src/eog-sidebar.c) by:
- * - Lucas Rocha <lucasr@gnome.org>
- *
- * 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 of the License, 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <string.h>
-#include <gtk/gtk.h>
-#include <gdk/gdkkeysyms.h>
-
-#include "empathy-sidebar.h"
-
-enum
-{
- PROP_0,
- PROP_CURRENT_PAGE
-};
-
-enum
-{
- PAGE_COLUMN_TITLE,
- PAGE_COLUMN_MENU_ITEM,
- PAGE_COLUMN_MAIN_WIDGET,
- PAGE_COLUMN_NOTEBOOK_INDEX,
- PAGE_COLUMN_NUM_COLS
-};
-
-enum
-{
- SIGNAL_PAGE_ADDED,
- SIGNAL_PAGE_REMOVED,
- SIGNAL_LAST
-};
-
-static gint signals[SIGNAL_LAST];
-
-struct _EmpathySidebarPrivate
-{
- GtkWidget *notebook;
- GtkWidget *select_button;
- GtkWidget *menu;
- GtkWidget *hbox;
- GtkWidget *label;
-
- GtkTreeModel *page_model;
-};
-
-G_DEFINE_TYPE (EmpathySidebar, empathy_sidebar, GTK_TYPE_VBOX)
-
-#define EMPATHY_SIDEBAR_GET_PRIVATE(object) \
- (G_TYPE_INSTANCE_GET_PRIVATE ((object), EMPATHY_TYPE_SIDEBAR, EmpathySidebarPrivate))
-
-static void
-empathy_sidebar_destroy (GtkWidget *object)
-{
- EmpathySidebar *sidebar = EMPATHY_SIDEBAR (object);
-
- if (sidebar->priv->menu)
- {
- gtk_menu_detach (GTK_MENU (sidebar->priv->menu));
- sidebar->priv->menu = NULL;
- }
-
- if (sidebar->priv->page_model)
- {
- g_object_unref (sidebar->priv->page_model);
- sidebar->priv->page_model = NULL;
- }
-
- (* GTK_WIDGET_CLASS (empathy_sidebar_parent_class)->destroy) (object);
-}
-
-static void
-empathy_sidebar_select_page (EmpathySidebar *sidebar,
- GtkTreeIter *iter)
-{
- gchar *title;
- gint index_;
-
- gtk_tree_model_get (sidebar->priv->page_model, iter,
- PAGE_COLUMN_TITLE, &title,
- PAGE_COLUMN_NOTEBOOK_INDEX, &index_,
- -1);
-
- gtk_notebook_set_current_page (GTK_NOTEBOOK (sidebar->priv->notebook),
- index_);
- gtk_label_set_text (GTK_LABEL (sidebar->priv->label), title);
-
- g_free (title);
-}
-
-void
-empathy_sidebar_set_page (EmpathySidebar *sidebar,
- GtkWidget *main_widget)
-{
- GtkTreeIter iter;
- gboolean valid;
-
- valid = gtk_tree_model_get_iter_first (sidebar->priv->page_model, &iter);
-
- while (valid)
- {
- GtkWidget *widget;
-
- gtk_tree_model_get (sidebar->priv->page_model, &iter,
- PAGE_COLUMN_MAIN_WIDGET, &widget,
- -1);
-
- if (widget == main_widget)
- {
- empathy_sidebar_select_page (sidebar, &iter);
- valid = FALSE;
- }
- else
- {
- valid = gtk_tree_model_iter_next (sidebar->priv->page_model, &iter);
- }
-
- g_object_unref (widget);
- }
-
- g_object_notify (G_OBJECT (sidebar), "current-page");
-}
-
-static GtkWidget *
-empathy_sidebar_get_current_page (EmpathySidebar *sidebar)
-{
- GtkNotebook *notebook = GTK_NOTEBOOK (sidebar->priv->notebook);
-
- return gtk_notebook_get_nth_page (
- notebook, gtk_notebook_get_current_page (notebook));
-}
-
-static void
-empathy_sidebar_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- EmpathySidebar *sidebar = EMPATHY_SIDEBAR (object);
-
- switch (prop_id)
- {
- case PROP_CURRENT_PAGE:
- empathy_sidebar_set_page (sidebar, g_value_get_object (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- }
-}
-
-static void
-empathy_sidebar_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- EmpathySidebar *sidebar = EMPATHY_SIDEBAR (object);
-
- switch (prop_id)
- {
- case PROP_CURRENT_PAGE:
- g_value_set_object (value,
- empathy_sidebar_get_current_page (sidebar));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- }
-}
-
-static void
-empathy_sidebar_class_init (EmpathySidebarClass *empathy_sidebar_class)
-{
- GObjectClass *g_object_class;
- GtkWidgetClass *widget_class;
-
- g_object_class = G_OBJECT_CLASS (empathy_sidebar_class);
- widget_class = GTK_WIDGET_CLASS (empathy_sidebar_class);
-
- g_type_class_add_private (g_object_class, sizeof (EmpathySidebarPrivate));
-
- widget_class->destroy = empathy_sidebar_destroy;
- g_object_class->get_property = empathy_sidebar_get_property;
- g_object_class->set_property = empathy_sidebar_set_property;
-
- g_object_class_install_property (g_object_class,
- PROP_CURRENT_PAGE,
- g_param_spec_object ("current-page",
- "Current page",
- "The currently visible page",
- GTK_TYPE_WIDGET,
- G_PARAM_READWRITE));
-
- signals[SIGNAL_PAGE_ADDED] = g_signal_new ("page-added",
- EMPATHY_TYPE_SIDEBAR, G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (EmpathySidebarClass, page_added),
- NULL, NULL, g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE, 1, GTK_TYPE_WIDGET);
-
- signals[SIGNAL_PAGE_REMOVED] = g_signal_new ("page-removed",
- EMPATHY_TYPE_SIDEBAR, G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (EmpathySidebarClass, page_removed),
- NULL, NULL, g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE, 1, GTK_TYPE_WIDGET);
-}
-
-static void
-empathy_sidebar_menu_position_under (GtkMenu *menu,
- gint *x,
- gint *y,
- gboolean *push_in,
- gpointer user_data)
-{
- GtkWidget *widget;
- GtkAllocation allocation;
-
- g_return_if_fail (GTK_IS_BUTTON (user_data));
- g_return_if_fail (!gtk_widget_get_has_window (user_data));
-
- widget = GTK_WIDGET (user_data);
-
- gdk_window_get_origin (gtk_widget_get_window (widget), x, y);
-
- gtk_widget_get_allocation (widget, &allocation);
- *x += allocation.x;
- *y += allocation.y + allocation.height;
-
- *push_in = FALSE;
-}
-
-static gboolean
-empathy_sidebar_select_button_press_cb (GtkWidget *widget,
- GdkEventButton *event,
- gpointer user_data)
-{
- EmpathySidebar *sidebar = EMPATHY_SIDEBAR (user_data);
-
- if (event->button == 1)
- {
- GtkRequisition requisition;
- gint width;
- GtkAllocation allocation;
-
- gtk_widget_get_allocation (widget, &allocation);
- width = allocation.width;
-
- gtk_widget_set_size_request (sidebar->priv->menu, -1, -1);
- gtk_widget_size_request (sidebar->priv->menu, &requisition);
- gtk_widget_set_size_request (sidebar->priv->menu,
- MAX (width, requisition.width), -1);
-
- gtk_widget_grab_focus (widget);
-
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
-
- gtk_menu_popup (GTK_MENU (sidebar->priv->menu),
- NULL, NULL, empathy_sidebar_menu_position_under, widget,
- event->button, event->time);
-
- return TRUE;
- }
-
- return FALSE;
-}
-
-static gboolean
-empathy_sidebar_select_button_key_press_cb (GtkWidget *widget,
- GdkEventKey *event,
- gpointer user_data)
-{
- EmpathySidebar *sidebar = EMPATHY_SIDEBAR (user_data);
-
- if (event->keyval == GDK_KEY_space ||
- event->keyval == GDK_KEY_KP_Space ||
- event->keyval == GDK_KEY_Return ||
- event->keyval == GDK_KEY_KP_Enter)
- {
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
-
- gtk_menu_popup (GTK_MENU (sidebar->priv->menu),
- NULL, NULL, empathy_sidebar_menu_position_under, widget,
- 1, event->time);
-
- return TRUE;
- }
-
- return FALSE;
-}
-
-static void
-empathy_sidebar_close_clicked_cb (GtkWidget *widget,
- gpointer user_data)
-{
- EmpathySidebar *sidebar = EMPATHY_SIDEBAR (user_data);
-
- gtk_widget_hide (GTK_WIDGET (sidebar));
-}
-
-static void
-empathy_sidebar_menu_deactivate_cb (GtkWidget *widget,
- gpointer user_data)
-{
- GtkWidget *menu_button;
-
- menu_button = GTK_WIDGET (user_data);
-
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (menu_button), FALSE);
-}
-
-static void
-empathy_sidebar_menu_detach_cb (GtkWidget *widget,
- GtkMenu *menu)
-{
- EmpathySidebar *sidebar = EMPATHY_SIDEBAR (widget);
-
- sidebar->priv->menu = NULL;
-}
-
-static void
-empathy_sidebar_menu_item_activate_cb (GtkWidget *widget,
- gpointer user_data)
-{
- EmpathySidebar *sidebar = EMPATHY_SIDEBAR (user_data);
- GtkTreeIter iter;
- GtkWidget *menu_item, *item;
- gboolean valid;
-
- menu_item = gtk_menu_get_active (GTK_MENU (sidebar->priv->menu));
- valid = gtk_tree_model_get_iter_first (sidebar->priv->page_model, &iter);
-
- while (valid)
- {
- gtk_tree_model_get (sidebar->priv->page_model, &iter,
- PAGE_COLUMN_MENU_ITEM, &item,
- -1);
-
- if (item == menu_item)
- {
- empathy_sidebar_select_page (sidebar, &iter);
- valid = FALSE;
- }
- else
- {
- valid = gtk_tree_model_iter_next (sidebar->priv->page_model, &iter);
- }
-
- g_object_unref (item);
- }
-
- g_object_notify (G_OBJECT (sidebar), "current-page");
-}
-
-static void
-empathy_sidebar_init (EmpathySidebar *sidebar)
-{
- GtkWidget *hbox;
- GtkWidget *close_button;
- GtkWidget *select_hbox;
- GtkWidget *arrow;
- GtkWidget *image;
-
- sidebar->priv = EMPATHY_SIDEBAR_GET_PRIVATE (sidebar);
-
- /* data model */
- sidebar->priv->page_model = (GtkTreeModel *) gtk_list_store_new (
- PAGE_COLUMN_NUM_COLS,
- G_TYPE_STRING,
- GTK_TYPE_WIDGET,
- GTK_TYPE_WIDGET,
- G_TYPE_INT);
-
- /* top option menu */
- hbox = gtk_hbox_new (FALSE, 0);
- sidebar->priv->hbox = hbox;
- gtk_box_pack_start (GTK_BOX (sidebar), hbox, FALSE, FALSE, 0);
- gtk_widget_show (hbox);
-
- sidebar->priv->select_button = gtk_toggle_button_new ();
- gtk_button_set_relief (GTK_BUTTON (sidebar->priv->select_button),
- GTK_RELIEF_NONE);
-
- g_signal_connect (sidebar->priv->select_button, "button_press_event",
- G_CALLBACK (empathy_sidebar_select_button_press_cb),
- sidebar);
-
- g_signal_connect (sidebar->priv->select_button, "key_press_event",
- G_CALLBACK (empathy_sidebar_select_button_key_press_cb),
- sidebar);
-
- select_hbox = gtk_hbox_new (FALSE, 0);
-
- sidebar->priv->label = gtk_label_new (NULL);
-
- gtk_box_pack_start (GTK_BOX (select_hbox),
- sidebar->priv->label,
- FALSE, FALSE, 0);
-
- gtk_widget_show (sidebar->priv->label);
-
- arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_NONE);
- gtk_box_pack_end (GTK_BOX (select_hbox), arrow, FALSE, FALSE, 0);
- gtk_widget_show (arrow);
-
- gtk_container_add (GTK_CONTAINER (sidebar->priv->select_button), select_hbox);
- gtk_widget_show (select_hbox);
-
- gtk_box_pack_start (GTK_BOX (hbox), sidebar->priv->select_button, TRUE, TRUE, 0);
- gtk_widget_show (sidebar->priv->select_button);
-
- close_button = gtk_button_new ();
-
- gtk_button_set_relief (GTK_BUTTON (close_button), GTK_RELIEF_NONE);
-
- g_signal_connect (close_button, "clicked",
- G_CALLBACK (empathy_sidebar_close_clicked_cb),
- sidebar);
-
- image = gtk_image_new_from_stock (GTK_STOCK_CLOSE,
- GTK_ICON_SIZE_MENU);
- gtk_container_add (GTK_CONTAINER (close_button), image);
- gtk_widget_show (image);
-
- gtk_box_pack_end (GTK_BOX (hbox), close_button, FALSE, FALSE, 0);
- gtk_widget_show (close_button);
-
- sidebar->priv->menu = gtk_menu_new ();
-
- g_signal_connect (sidebar->priv->menu, "deactivate",
- G_CALLBACK (empathy_sidebar_menu_deactivate_cb),
- sidebar->priv->select_button);
-
- gtk_menu_attach_to_widget (GTK_MENU (sidebar->priv->menu),
- GTK_WIDGET (sidebar),
- empathy_sidebar_menu_detach_cb);
-
- gtk_widget_show (sidebar->priv->menu);
-
- sidebar->priv->notebook = gtk_notebook_new ();
-
- gtk_notebook_set_show_border (GTK_NOTEBOOK (sidebar->priv->notebook), FALSE);
- gtk_notebook_set_show_tabs (GTK_NOTEBOOK (sidebar->priv->notebook), FALSE);
-
- gtk_box_pack_start (GTK_BOX (sidebar), sidebar->priv->notebook,
- TRUE, TRUE, 0);
-
- gtk_widget_show (sidebar->priv->notebook);
-}
-
-GtkWidget *
-empathy_sidebar_new (void)
-{
- GtkWidget *sidebar;
-
- sidebar = g_object_new (EMPATHY_TYPE_SIDEBAR, NULL);
-
- return sidebar;
-}
-
-void
-empathy_sidebar_add_page (EmpathySidebar *sidebar,
- const gchar *title,
- GtkWidget *main_widget)
-{
- GtkTreeIter iter;
- GtkWidget *menu_item;
- gchar *label_title;
- gint index_;
-
- g_return_if_fail (EMPATHY_IS_SIDEBAR (sidebar));
- g_return_if_fail (GTK_IS_WIDGET (main_widget));
-
- index_ = gtk_notebook_append_page (GTK_NOTEBOOK (sidebar->priv->notebook),
- main_widget, NULL);
-
- menu_item = gtk_image_menu_item_new_with_label (title);
-
- g_signal_connect (menu_item, "activate",
- G_CALLBACK (empathy_sidebar_menu_item_activate_cb),
- sidebar);
-
- gtk_widget_show (menu_item);
-
- gtk_menu_shell_append (GTK_MENU_SHELL (sidebar->priv->menu),
- menu_item);
-
- /* Insert and move to end */
- gtk_list_store_insert_with_values (GTK_LIST_STORE (sidebar->priv->page_model),
- &iter, 0,
- PAGE_COLUMN_TITLE, title,
- PAGE_COLUMN_MENU_ITEM, menu_item,
- PAGE_COLUMN_MAIN_WIDGET, main_widget,
- PAGE_COLUMN_NOTEBOOK_INDEX, index_,
- -1);
-
- gtk_list_store_move_before (GTK_LIST_STORE(sidebar->priv->page_model),
- &iter,
- NULL);
-
- /* Set the first item added as active */
- gtk_tree_model_get_iter_first (sidebar->priv->page_model, &iter);
- gtk_tree_model_get (sidebar->priv->page_model,
- &iter,
- PAGE_COLUMN_TITLE, &label_title,
- PAGE_COLUMN_NOTEBOOK_INDEX, &index_,
- -1);
-
- gtk_menu_set_active (GTK_MENU (sidebar->priv->menu), index_);
-
- gtk_label_set_text (GTK_LABEL (sidebar->priv->label), label_title);
-
- gtk_notebook_set_current_page (GTK_NOTEBOOK (sidebar->priv->notebook),
- index_);
-
- g_free (label_title);
-
- g_signal_emit (G_OBJECT (sidebar), signals[SIGNAL_PAGE_ADDED],
- 0, main_widget);
-}
-
-void
-empathy_sidebar_remove_page (EmpathySidebar *sidebar,
- GtkWidget *main_widget)
-{
- GtkTreeIter iter;
- GtkWidget *widget, *menu_item;
- gboolean valid;
- gint index_;
-
- g_return_if_fail (EMPATHY_IS_SIDEBAR (sidebar));
- g_return_if_fail (GTK_IS_WIDGET (main_widget));
-
- valid = gtk_tree_model_get_iter_first (sidebar->priv->page_model, &iter);
-
- while (valid)
- {
- gtk_tree_model_get (sidebar->priv->page_model, &iter,
- PAGE_COLUMN_NOTEBOOK_INDEX, &index_,
- PAGE_COLUMN_MENU_ITEM, &menu_item,
- PAGE_COLUMN_MAIN_WIDGET, &widget,
- -1);
-
- if (widget == main_widget)
- break;
- else
- valid = gtk_tree_model_iter_next (sidebar->priv->page_model, &iter);
-
- g_object_unref (menu_item);
- g_object_unref (widget);
- }
-
- if (valid)
- {
- gtk_notebook_remove_page (GTK_NOTEBOOK (sidebar->priv->notebook),
- index_);
-
- gtk_container_remove (GTK_CONTAINER (sidebar->priv->menu), menu_item);
-
- gtk_list_store_remove (GTK_LIST_STORE (sidebar->priv->page_model),
- &iter);
-
- g_signal_emit (G_OBJECT (sidebar),
- signals[SIGNAL_PAGE_REMOVED], 0, main_widget);
- }
-}
-
-gint
-empathy_sidebar_get_n_pages (EmpathySidebar *sidebar)
-{
- g_return_val_if_fail (EMPATHY_IS_SIDEBAR (sidebar), TRUE);
-
- return gtk_tree_model_iter_n_children (
- GTK_TREE_MODEL (sidebar->priv->page_model), NULL);
-}
-
-gboolean
-empathy_sidebar_is_empty (EmpathySidebar *sidebar)
-{
- g_return_val_if_fail (EMPATHY_IS_SIDEBAR (sidebar), TRUE);
-
- return gtk_tree_model_iter_n_children (
- GTK_TREE_MODEL (sidebar->priv->page_model), NULL) == 0;
-}
diff --git a/src/empathy-sidebar.h b/src/empathy-sidebar.h
deleted file mode 100644
index 095336fac..000000000
--- a/src/empathy-sidebar.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright (C) 2004 Red Hat, Inc.
- * Copyright (C) 2007 The Free Software Foundation
- * Copyright (C) 2008 Marco Barisione <marco@barisione.org>
- *
- * Based on evince code (shell/ev-sidebar.h) by:
- * - Jonathan Blandford <jrb@alum.mit.edu>
- *
- * Base on eog code (src/eog-sidebar.c) by:
- * - Lucas Rocha <lucasr@gnome.org>
- *
- * 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 of the License, 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef __EMPATHY_SIDEBAR_H__
-#define __EMPATHY_SIDEBAR_H__
-
-#include <gtk/gtk.h>
-
-G_BEGIN_DECLS
-
-typedef struct _EmpathySidebar EmpathySidebar;
-typedef struct _EmpathySidebarClass EmpathySidebarClass;
-typedef struct _EmpathySidebarPrivate EmpathySidebarPrivate;
-
-#define EMPATHY_TYPE_SIDEBAR (empathy_sidebar_get_type())
-#define EMPATHY_SIDEBAR(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), EMPATHY_TYPE_SIDEBAR, EmpathySidebar))
-#define EMPATHY_SIDEBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), EMPATHY_TYPE_SIDEBAR, EmpathySidebarClass))
-#define EMPATHY_IS_SIDEBAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), EMPATHY_TYPE_SIDEBAR))
-#define EMPATHY_IS_SIDEBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), EMPATHY_TYPE_SIDEBAR))
-#define EMPATHY_SIDEBAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), EMPATHY_TYPE_SIDEBAR, EmpathySidebarClass))
-
-struct _EmpathySidebar
-{
- GtkVBox base_instance;
-
- EmpathySidebarPrivate *priv;
-};
-
-struct _EmpathySidebarClass
-{
- GtkVBoxClass base_class;
-
- void (* page_added) (EmpathySidebar *sidebar,
- GtkWidget *main_widget);
-
- void (* page_removed) (EmpathySidebar *sidebar,
- GtkWidget *main_widget);
-};
-
-GType empathy_sidebar_get_type (void);
-
-GtkWidget *empathy_sidebar_new (void);
-
-void empathy_sidebar_add_page (EmpathySidebar *sidebar,
- const gchar *title,
- GtkWidget *main_widget);
-
-void empathy_sidebar_remove_page (EmpathySidebar *sidebar,
- GtkWidget *main_widget);
-
-void empathy_sidebar_set_page (EmpathySidebar *sidebar,
- GtkWidget *main_widget);
-
-gint empathy_sidebar_get_n_pages (EmpathySidebar *sidebar);
-
-gboolean empathy_sidebar_is_empty (EmpathySidebar *sidebar);
-
-G_END_DECLS
-
-#endif /* __EMPATHY_SIDEBAR_H__ */
-
-
diff --git a/src/ev-sidebar.c b/src/ev-sidebar.c
new file mode 100644
index 000000000..d0dd2b615
--- /dev/null
+++ b/src/ev-sidebar.c
@@ -0,0 +1,338 @@
+/* this file is part of evince, a gnome document viewer
+ *
+ * Copyright (C) 2004 Red Hat, Inc.
+ * (C) 2007 Jan Arne Petersen
+ *
+ * Authors:
+ * Jonathan Blandford <jrb@alum.mit.edu>
+ * Jan Arne Petersen <jpetersen@jpetersen.org>
+ *
+ * Evince 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 of the License, or
+ * (at your option) any later version.
+ *
+ * Evince 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 02110-1301 USA.
+ *
+ * Thursday 03 May 2007: Bastien Nocera: Add exception clause.
+ * See license_change file for details.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <string.h>
+#include <gtk/gtk.h>
+#include <gdk/gdkkeysyms.h>
+
+#include "ev-sidebar.h"
+
+enum
+{
+ PAGE_COLUMN_ID,
+ PAGE_COLUMN_TITLE,
+ PAGE_COLUMN_NUM_COLS
+};
+
+struct _EvSidebarPrivate {
+ GtkWidget *combobox;
+ GtkWidget *notebook;
+};
+
+enum {
+ CLOSED,
+ LAST_SIGNAL
+};
+
+static int ev_sidebar_table_signals[LAST_SIGNAL] = { 0 };
+
+G_DEFINE_TYPE (EvSidebar, ev_sidebar, GTK_TYPE_VBOX)
+
+#define EV_SIDEBAR_GET_PRIVATE(object) \
+ (G_TYPE_INSTANCE_GET_PRIVATE ((object), EV_TYPE_SIDEBAR, EvSidebarPrivate))
+
+static void
+ev_sidebar_class_init (EvSidebarClass *ev_sidebar_class)
+{
+ GObjectClass *g_object_class;
+ GtkWidgetClass *widget_class;
+
+ g_object_class = G_OBJECT_CLASS (ev_sidebar_class);
+ widget_class = GTK_WIDGET_CLASS (ev_sidebar_class);
+
+ g_type_class_add_private (g_object_class, sizeof (EvSidebarPrivate));
+
+ ev_sidebar_table_signals[CLOSED] =
+ g_signal_new ("closed",
+ G_TYPE_FROM_CLASS (g_object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (EvSidebarClass, closed),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
+}
+
+static void
+ev_sidebar_close_clicked_cb (GtkWidget *widget,
+ gpointer user_data)
+{
+ EvSidebar *ev_sidebar = EV_SIDEBAR (user_data);
+
+ g_signal_emit (G_OBJECT (ev_sidebar),
+ ev_sidebar_table_signals[CLOSED], 0, NULL);
+ gtk_widget_hide (GTK_WIDGET (ev_sidebar));
+}
+
+static void
+ev_sidebar_combobox_changed_cb (GtkComboBox *combo_box,
+ gpointer user_data)
+{
+ EvSidebar *ev_sidebar = EV_SIDEBAR (user_data);
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+
+ model = gtk_combo_box_get_model (combo_box);
+
+ if (gtk_combo_box_get_active_iter (combo_box, &iter)) {
+ GtkTreePath *path;
+ gint *indices;
+
+ path = gtk_tree_model_get_path (model, &iter);
+ indices = gtk_tree_path_get_indices (path);
+
+ if (indices != NULL) {
+ gtk_notebook_set_current_page (GTK_NOTEBOOK (ev_sidebar->priv->notebook), indices[0]);
+ }
+
+ gtk_tree_path_free (path);
+ }
+}
+
+static void
+ev_sidebar_init (EvSidebar *ev_sidebar)
+{
+ GtkTreeModel *page_model;
+ GtkWidget *vbox, *hbox;
+ GtkWidget *close_button;
+ GtkCellRenderer *renderer;
+ GtkWidget *image;
+
+ ev_sidebar->priv = EV_SIDEBAR_GET_PRIVATE (ev_sidebar);
+
+ /* data model */
+ page_model = (GtkTreeModel *)
+ gtk_list_store_new (PAGE_COLUMN_NUM_COLS,
+ G_TYPE_STRING,
+ G_TYPE_STRING,
+ GTK_TYPE_WIDGET,
+ G_TYPE_INT);
+
+ /* create a 6 6 6 0 border with GtkBoxes */
+ hbox = gtk_hbox_new (FALSE, 6);
+ gtk_box_pack_start (GTK_BOX (ev_sidebar), hbox, TRUE, TRUE, 6);
+
+ vbox = gtk_vbox_new (FALSE, 6);
+ gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (hbox), gtk_vbox_new (FALSE, 0), FALSE, FALSE, 0);
+
+ /* top option menu */
+ hbox = gtk_hbox_new (FALSE, 6);
+ gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
+ gtk_widget_show (hbox);
+
+ ev_sidebar->priv->combobox = gtk_combo_box_new_with_model (page_model);
+ g_signal_connect (ev_sidebar->priv->combobox, "changed",
+ G_CALLBACK (ev_sidebar_combobox_changed_cb),
+ ev_sidebar);
+
+ renderer = gtk_cell_renderer_text_new ();
+ gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (ev_sidebar->priv->combobox), renderer, TRUE);
+ gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (ev_sidebar->priv->combobox), renderer, "text", PAGE_COLUMN_TITLE);
+
+ gtk_box_pack_start (GTK_BOX (hbox), ev_sidebar->priv->combobox, TRUE, TRUE, 0);
+ gtk_widget_show (ev_sidebar->priv->combobox);
+
+ g_object_unref (G_OBJECT (page_model));
+
+ close_button = gtk_button_new ();
+ gtk_button_set_relief (GTK_BUTTON (close_button), GTK_RELIEF_NONE);
+ g_signal_connect (close_button, "clicked",
+ G_CALLBACK (ev_sidebar_close_clicked_cb),
+ ev_sidebar);
+
+ image = gtk_image_new_from_stock (GTK_STOCK_CLOSE,
+ GTK_ICON_SIZE_MENU);
+ gtk_container_add (GTK_CONTAINER (close_button), image);
+ gtk_widget_show (image);
+
+ gtk_box_pack_end (GTK_BOX (hbox), close_button, FALSE, FALSE, 0);
+ gtk_widget_show (close_button);
+
+ ev_sidebar->priv->notebook = gtk_notebook_new ();
+ gtk_notebook_set_show_border (GTK_NOTEBOOK (ev_sidebar->priv->notebook), FALSE);
+ gtk_notebook_set_show_tabs (GTK_NOTEBOOK (ev_sidebar->priv->notebook), FALSE);
+ gtk_box_pack_start (GTK_BOX (vbox), ev_sidebar->priv->notebook,
+ TRUE, TRUE, 0);
+ gtk_widget_show (ev_sidebar->priv->notebook);
+}
+
+/* Public functions */
+
+GtkWidget *
+ev_sidebar_new (void)
+{
+ GtkWidget *ev_sidebar;
+
+ ev_sidebar = g_object_new (EV_TYPE_SIDEBAR, NULL);
+
+ return ev_sidebar;
+}
+
+/* NOTE: Return values from this have to be g_free()d */
+char *
+ev_sidebar_get_current_page (EvSidebar *ev_sidebar)
+{
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ char *id;
+
+ g_return_val_if_fail (EV_IS_SIDEBAR (ev_sidebar), NULL);
+ g_return_val_if_fail (ev_sidebar->priv != NULL, NULL);
+
+ model = gtk_combo_box_get_model (GTK_COMBO_BOX (ev_sidebar->priv->combobox));
+
+ if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (ev_sidebar->priv->combobox), &iter)) {
+ gtk_tree_model_get (model, &iter, PAGE_COLUMN_ID, &id, -1);
+
+ return id;
+ }
+
+ return NULL;
+}
+
+static gboolean
+ev_sidebar_get_iter_for_page_id (EvSidebar *ev_sidebar,
+ const char *new_page_id,
+ GtkTreeIter *iter)
+{
+ GtkTreeModel *model;
+ gboolean valid;
+ gchar *page_id;
+
+ g_return_val_if_fail (EV_IS_SIDEBAR (ev_sidebar), FALSE);
+ g_return_val_if_fail (ev_sidebar->priv != NULL, FALSE);
+ g_return_val_if_fail (iter != NULL, FALSE);
+
+ model = gtk_combo_box_get_model (GTK_COMBO_BOX (ev_sidebar->priv->combobox));
+
+ valid = gtk_tree_model_get_iter_first (model, iter);
+
+ while (valid) {
+ gtk_tree_model_get (model, iter, PAGE_COLUMN_ID, &page_id, -1);
+
+ if (page_id != NULL && strcmp (new_page_id, page_id) == 0) {
+ g_free (page_id);
+ return TRUE;
+ }
+ g_free (page_id);
+
+ valid = gtk_tree_model_iter_next (model, iter);
+ }
+
+ return FALSE;
+}
+
+void
+ev_sidebar_set_current_page (EvSidebar *ev_sidebar, const char *new_page_id)
+{
+ GtkTreeIter iter;
+
+ g_return_if_fail (EV_IS_SIDEBAR (ev_sidebar));
+ g_return_if_fail (new_page_id != NULL);
+
+
+ if (ev_sidebar_get_iter_for_page_id (ev_sidebar, new_page_id, &iter)) {
+ gtk_combo_box_set_active_iter (GTK_COMBO_BOX (ev_sidebar->priv->combobox), &iter);
+ }
+}
+
+void
+ev_sidebar_add_page (EvSidebar *ev_sidebar,
+ const gchar *page_id,
+ const gchar *title,
+ GtkWidget *main_widget)
+{
+ GtkTreeIter iter, iter2;
+ GtkTreeModel *model;
+
+ g_return_if_fail (EV_IS_SIDEBAR (ev_sidebar));
+ g_return_if_fail (page_id != NULL);
+ g_return_if_fail (title != NULL);
+ g_return_if_fail (GTK_IS_WIDGET (main_widget));
+
+ model = gtk_combo_box_get_model (GTK_COMBO_BOX (ev_sidebar->priv->combobox));
+
+ gtk_widget_set_sensitive (GTK_WIDGET (ev_sidebar), TRUE);
+
+ gtk_widget_show (main_widget);
+ gtk_notebook_append_page (GTK_NOTEBOOK (ev_sidebar->priv->notebook), main_widget, NULL);
+
+ gtk_list_store_append (GTK_LIST_STORE (model), &iter);
+ gtk_list_store_set (GTK_LIST_STORE (model), &iter,
+ PAGE_COLUMN_ID, page_id,
+ PAGE_COLUMN_TITLE, title,
+ -1);
+
+ if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX (ev_sidebar->priv->combobox), &iter2)) {
+ gtk_combo_box_set_active_iter (GTK_COMBO_BOX (ev_sidebar->priv->combobox), &iter);
+ }
+}
+
+void
+ev_sidebar_remove_page (EvSidebar *ev_sidebar,
+ const gchar *page_id)
+{
+ GtkTreeIter iter;
+ GtkTreeModel *model;
+
+ g_return_if_fail (EV_IS_SIDEBAR (ev_sidebar));
+ g_return_if_fail (page_id != NULL);
+
+ model = gtk_combo_box_get_model (GTK_COMBO_BOX (ev_sidebar->priv->combobox));
+
+ if (ev_sidebar_get_iter_for_page_id (ev_sidebar, page_id, &iter)) {
+ GtkTreePath *path;
+ gint *indices;
+
+ path = gtk_tree_model_get_path (model, &iter);
+ indices = gtk_tree_path_get_indices (path);
+
+ g_assert (indices != NULL);
+ gtk_notebook_remove_page (GTK_NOTEBOOK (ev_sidebar->priv->notebook), indices[0]);
+
+ gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
+
+ if (gtk_tree_model_iter_n_children (model, NULL) != 0) {
+ gtk_tree_path_prev (path);
+
+ if (gtk_tree_model_get_iter (model, &iter, path)) {
+ gtk_combo_box_set_active_iter (GTK_COMBO_BOX (ev_sidebar->priv->combobox), &iter);
+ }
+ } else {
+ gtk_widget_set_sensitive (GTK_WIDGET (ev_sidebar), FALSE);
+ }
+
+ gtk_tree_path_free (path);
+ }
+}
+
diff --git a/src/ev-sidebar.h b/src/ev-sidebar.h
new file mode 100644
index 000000000..cfb57f2eb
--- /dev/null
+++ b/src/ev-sidebar.h
@@ -0,0 +1,76 @@
+/* ev-sidebar.h
+ * this file is part of evince, a gnome document viewer
+ *
+ * Copyright (C) 2004 Red Hat, Inc.
+ *
+ * Author:
+ * Jonathan Blandford <jrb@alum.mit.edu>
+ *
+ * Evince 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 of the License, or
+ * (at your option) any later version.
+ *
+ * Evince 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 02110-1301 USA.
+ *
+ * Thursday 03 May 2007: Bastien Nocera: Add exception clause.
+ * See license_change file for details.
+ *
+ */
+
+#ifndef __EV_SIDEBAR_H__
+#define __EV_SIDEBAR_H__
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+typedef struct _EvSidebar EvSidebar;
+typedef struct _EvSidebarClass EvSidebarClass;
+typedef struct _EvSidebarPrivate EvSidebarPrivate;
+
+#define EV_TYPE_SIDEBAR (ev_sidebar_get_type())
+#define EV_SIDEBAR(object) (G_TYPE_CHECK_INSTANCE_CAST((object), EV_TYPE_SIDEBAR, EvSidebar))
+#define EV_SIDEBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), EV_TYPE_SIDEBAR, EvSidebarClass))
+#define EV_IS_SIDEBAR(object) (G_TYPE_CHECK_INSTANCE_TYPE((object), EV_TYPE_SIDEBAR))
+#define EV_IS_SIDEBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), EV_TYPE_SIDEBAR))
+#define EV_SIDEBAR_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS((object), EV_TYPE_SIDEBAR, EvSidebarClass))
+
+struct _EvSidebar {
+ GtkVBox base_instance;
+
+ EvSidebarPrivate *priv;
+};
+
+struct _EvSidebarClass {
+ GtkVBoxClass base_class;
+
+ void (*closed) (EvSidebar *sidebar);
+};
+
+GType ev_sidebar_get_type (void);
+GtkWidget *ev_sidebar_new (void);
+void ev_sidebar_add_page (EvSidebar *ev_sidebar,
+ const gchar *page_id,
+ const gchar *title,
+ GtkWidget *main_widget);
+void ev_sidebar_set_current_page
+ (EvSidebar *ev_sidebar,
+ const char *page_id);
+char *ev_sidebar_get_current_page
+ (EvSidebar *ev_sidebar);
+void ev_sidebar_remove_page (EvSidebar *ev_sidebar,
+ const gchar *page_id);
+
+G_END_DECLS
+
+#endif /* __EV_SIDEBAR_H__ */
+
+