diff options
author | Iulian Radu <iulian.radu67@gmail.com> | 2016-09-27 19:02:26 +0300 |
---|---|---|
committer | Iulian Radu <iulian.radu67@gmail.com> | 2016-09-28 16:15:13 +0300 |
commit | 74815f5b23be10be5acdbd5a117de4ea3b8b0100 (patch) | |
tree | 0edda7c87133a5ceeeaf74aeeecd79278a0cc7f1 | |
parent | d0b0aa4e94dd43f6c0cc6b6604be074b0251fafc (diff) | |
download | epiphany-74815f5b23be10be5acdbd5a117de4ea3b8b0100.tar.gz |
Remove obsolete EphyBookmarkProperties
-rw-r--r-- | src/bookmarks/Makefile.am | 2 | ||||
-rw-r--r-- | src/bookmarks/ephy-bookmark-properties.c | 442 | ||||
-rw-r--r-- | src/bookmarks/ephy-bookmark-properties.h | 38 | ||||
-rw-r--r-- | src/bookmarks/ephy-bookmarks-ui.c | 58 | ||||
-rw-r--r-- | src/bookmarks/ephy-bookmarks.c | 1 |
5 files changed, 0 insertions, 541 deletions
diff --git a/src/bookmarks/Makefile.am b/src/bookmarks/Makefile.am index 0e3a59cc5..0b1f539a2 100644 --- a/src/bookmarks/Makefile.am +++ b/src/bookmarks/Makefile.am @@ -10,8 +10,6 @@ libephybookmarks_la_SOURCES = \ ephy-bookmark-action.h \ ephy-bookmarks-ui.c \ ephy-bookmarks-ui.h \ - ephy-bookmark-properties.c \ - ephy-bookmark-properties.h \ ephy-link-action.c \ ephy-link-action.h \ ephy-topic-action.c \ diff --git a/src/bookmarks/ephy-bookmark-properties.c b/src/bookmarks/ephy-bookmark-properties.c deleted file mode 100644 index 32489c05f..000000000 --- a/src/bookmarks/ephy-bookmark-properties.c +++ /dev/null @@ -1,442 +0,0 @@ -/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* - * Copyright © 2002 Marco Pesenti Gritti <mpeseng@tin.it> - * Copyright © 2005, 2006 Peter A. Harvey - * Copyright © 2006 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 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, see <http://www.gnu.org/licenses/>. - */ - -#include "config.h" - -#include "ephy-bookmark-properties.h" - -#include "ephy-bookmarks-ui.h" -#include "ephy-node-common.h" -#include "ephy-debug.h" -#include "ephy-shell.h" -#include "ephy-initial-state.h" -#include "ephy-gui.h" -#include "ephy-dnd.h" -#include "ephy-prefs.h" -#include "ephy-settings.h" -#include "ephy-uri-helpers.h" - -#include <glib/gi18n.h> -#include <gtk/gtk.h> - -#include <string.h> - -struct _EphyBookmarkProperties { - GtkDialog parent_instance; - - /* construct properties */ - EphyBookmarks *bookmarks; - EphyNode *bookmark; - gboolean creating; - - /* counters */ - gint duplicate_count; - gint duplicate_idle; - - /* from UI file */ - GtkGrid *grid; - GtkEntry *title_entry; - GtkEntry *adress_entry; - GtkLabel *topics_label; - GtkExpander *topics_expander; - GtkTreeView *topics_tree_view; - GtkScrolledWindow *topics_scrolled_window; - GtkLabel *warning_label; -}; - -enum { - PROP_0, - PROP_BOOKMARKS, - PROP_BOOKMARK, - PROP_CREATING, - LAST_PROP -}; - -static GParamSpec *obj_properties[LAST_PROP]; - -G_DEFINE_TYPE (EphyBookmarkProperties, ephy_bookmark_properties, GTK_TYPE_DIALOG) - -static gboolean -update_warning (EphyBookmarkProperties *properties) -{ - char *label; - - properties->duplicate_idle = 0; - properties->duplicate_count = ephy_bookmarks_get_similar - (properties->bookmarks, properties->bookmark, NULL, NULL); - - /* Translators: This string is used when counting bookmarks that - * are similar to each other */ - label = g_strdup_printf (ngettext ("%d bookmark is similar", "%d bookmarks are similar", properties->duplicate_count), properties->duplicate_count); - gtk_label_set_text (properties->warning_label, label); - g_free (label); - - return FALSE; -} - -static void -update_warning_idle (EphyBookmarkProperties *properties) -{ - if (properties->duplicate_idle != 0) { - g_source_remove (properties->duplicate_idle); - } - - properties->duplicate_idle = g_timeout_add - (500, (GSourceFunc)update_warning, properties); - g_source_set_name_by_id (properties->duplicate_idle, "[epiphany] update_warning"); -} - -static void -node_added_cb (EphyNode *bookmarks, - EphyNode *bookmark, - EphyBookmarkProperties *properties) -{ - update_warning_idle (properties); -} - -static void -node_changed_cb (EphyNode *bookmarks, - EphyNode *bookmark, - guint property, - EphyBookmarkProperties *properties) -{ - if (property == EPHY_NODE_BMK_PROP_LOCATION) { - update_warning_idle (properties); - } -} - -static void -node_removed_cb (EphyNode *bookmarks, - EphyNode *bookmark, - guint index, - EphyBookmarkProperties *properties) -{ - update_warning_idle (properties); -} - -static void -node_destroy_cb (EphyNode *bookmark, - GtkWidget *dialog) -{ - EPHY_BOOKMARK_PROPERTIES (dialog)->creating = FALSE; - gtk_widget_destroy (dialog); -} - -static void -ephy_bookmark_properties_set_bookmark (EphyBookmarkProperties *properties, - EphyNode *bookmark) -{ - LOG ("Set bookmark"); - - if (properties->bookmark) { - ephy_node_signal_disconnect_object (properties->bookmark, - EPHY_NODE_DESTROY, - (EphyNodeCallback)node_destroy_cb, - G_OBJECT (properties)); - } - - properties->bookmark = bookmark; - - ephy_node_signal_connect_object (properties->bookmark, - EPHY_NODE_DESTROY, - (EphyNodeCallback)node_destroy_cb, - G_OBJECT (properties)); -} - -static void -ephy_bookmark_properties_destroy_cb (GtkDialog *dialog, - gpointer data) -{ - EphyBookmarkProperties *properties = EPHY_BOOKMARK_PROPERTIES (dialog); - - if (properties->creating) { - ephy_node_unref (properties->bookmark); - properties->creating = FALSE; - } - - if (properties->duplicate_idle != 0) { - g_source_remove (properties->duplicate_idle); - properties->duplicate_idle = 0; - } -} - -static void -ephy_bookmark_properties_response_cb (GtkDialog *dialog, - int response_id, - gpointer data) -{ - EphyBookmarkProperties *properties = EPHY_BOOKMARK_PROPERTIES (dialog); - - switch (response_id) { - case GTK_RESPONSE_ACCEPT: - properties->creating = FALSE; - break; - default: - break; - } - - gtk_widget_destroy (GTK_WIDGET (dialog)); -} - -static void -update_entry (EphyBookmarkProperties *properties, - GtkWidget *entry, - guint prop) -{ - GValue value = { 0, }; - char *text; - - text = gtk_editable_get_chars (GTK_EDITABLE (entry), 0, -1); - g_value_init (&value, G_TYPE_STRING); - g_value_take_string (&value, text); - ephy_node_set_property (properties->bookmark, - prop, - &value); - g_value_unset (&value); -} - -static void -update_window_title (EphyBookmarkProperties *properties) -{ - char *title; - const char *tmp; - - tmp = ephy_node_get_property_string (properties->bookmark, - EPHY_NODE_BMK_PROP_TITLE); - - if (properties->creating) - title = g_strdup (_("Add Bookmark")); - else - title = g_strdup_printf (_("“%s” Properties"), tmp); - - gtk_window_set_title (GTK_WINDOW (properties), title); - g_free (title); -} - -static void -title_entry_changed_cb (GtkWidget *entry, - EphyBookmarkProperties *properties) -{ - update_entry (properties, entry, EPHY_NODE_BMK_PROP_TITLE); - update_window_title (properties); -} - -static void -location_entry_changed_cb (GtkWidget *entry, - EphyBookmarkProperties *properties) -{ - ephy_bookmarks_set_address (properties->bookmarks, - properties->bookmark, - gtk_entry_get_text (GTK_ENTRY (entry))); -} - -static void -ephy_bookmark_properties_init (EphyBookmarkProperties *properties) -{ -} - -static GObject * -ephy_bookmark_properties_constructor (GType type, - guint n_construct_properties, - GObjectConstructParam *construct_params) -{ - GObject *object; - EphyBookmarkProperties *properties; - - gboolean lockdown; - const char *tmp; - char *decoded_url; - - object = G_OBJECT_CLASS (ephy_bookmark_properties_parent_class)->constructor (type, - n_construct_properties, - construct_params); - properties = EPHY_BOOKMARK_PROPERTIES (object); - - gtk_widget_init_template (GTK_WIDGET (properties)); - - if (!properties->creating) { - ephy_initial_state_add_window (GTK_WIDGET (properties), - "bookmark_properties", - 290, 280, FALSE, - EPHY_INITIAL_STATE_WINDOW_SAVE_POSITION | - EPHY_INITIAL_STATE_WINDOW_SAVE_SIZE); - } - /* Lockdown */ - lockdown = g_settings_get_boolean (EPHY_SETTINGS_LOCKDOWN, - EPHY_PREFS_LOCKDOWN_BOOKMARK_EDITING); - - update_window_title (properties); - - gtk_editable_set_editable (GTK_EDITABLE (properties->title_entry), !lockdown); - tmp = ephy_node_get_property_string (properties->bookmark, EPHY_NODE_BMK_PROP_TITLE); - gtk_entry_set_text (properties->title_entry, tmp); - - gtk_editable_set_editable (GTK_EDITABLE (properties->adress_entry), !lockdown); - tmp = ephy_node_get_property_string (properties->bookmark, EPHY_NODE_BMK_PROP_LOCATION); - decoded_url = ephy_uri_decode (tmp); - gtk_entry_set_text (properties->adress_entry, decoded_url); - g_free (decoded_url); - - /* TODO bind; and the entry?! */ - gtk_widget_set_sensitive (GTK_WIDGET (properties->topics_scrolled_window), !lockdown); - - ephy_initial_state_add_expander (GTK_WIDGET (properties->topics_expander), "bookmark_properties_list", FALSE); - - if (properties->creating) { - gtk_dialog_add_button (GTK_DIALOG (properties), _("_Cancel"), GTK_RESPONSE_CANCEL); - gtk_dialog_add_button (GTK_DIALOG (properties), _("_Add"), GTK_RESPONSE_ACCEPT); - gtk_dialog_set_default_response (GTK_DIALOG (properties), GTK_RESPONSE_ACCEPT); - } - - update_warning (properties); - - return object; -} - -static void -ephy_bookmark_properties_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - EphyBookmarkProperties *properties = EPHY_BOOKMARK_PROPERTIES (object); - EphyNode *bookmarks; - - switch (prop_id) { - case PROP_BOOKMARKS: - properties->bookmarks = g_value_get_object (value); - bookmarks = ephy_bookmarks_get_bookmarks (properties->bookmarks); - ephy_node_signal_connect_object (bookmarks, - EPHY_NODE_CHILD_ADDED, - (EphyNodeCallback)node_added_cb, - object); - ephy_node_signal_connect_object (bookmarks, - EPHY_NODE_CHILD_REMOVED, - (EphyNodeCallback)node_removed_cb, - object); - ephy_node_signal_connect_object (bookmarks, - EPHY_NODE_CHILD_CHANGED, - (EphyNodeCallback)node_changed_cb, - object); - break; - case PROP_BOOKMARK: - ephy_bookmark_properties_set_bookmark - (properties, g_value_get_pointer (value)); - break; - case PROP_CREATING: - properties->creating = g_value_get_boolean (value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -ephy_bookmark_properties_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - EphyBookmarkProperties *properties = EPHY_BOOKMARK_PROPERTIES (object); - - switch (prop_id) { - case PROP_BOOKMARK: - g_value_set_object (value, properties); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -ephy_bookmark_properties_class_init (EphyBookmarkPropertiesClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); - - object_class->constructor = ephy_bookmark_properties_constructor; - object_class->set_property = ephy_bookmark_properties_set_property; - object_class->get_property = ephy_bookmark_properties_get_property; - - obj_properties[PROP_BOOKMARKS] = - g_param_spec_object ("bookmarks", - "bookmarks", - "bookmarks", - EPHY_TYPE_BOOKMARKS, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY); - - obj_properties[PROP_BOOKMARK] = - g_param_spec_pointer ("bookmark", - "bookmark", - "bookmark", - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT); - - obj_properties[PROP_CREATING] = - g_param_spec_boolean ("creating", - "creating", - "creating", - FALSE, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY); - - g_object_class_install_properties (object_class, LAST_PROP, obj_properties); - - /* from UI file */ - gtk_widget_class_set_template_from_resource (widget_class, - "/org/gnome/epiphany/bookmark-properties.ui"); - - gtk_widget_class_bind_template_child (widget_class, EphyBookmarkProperties, grid); - gtk_widget_class_bind_template_child (widget_class, EphyBookmarkProperties, title_entry); - gtk_widget_class_bind_template_child (widget_class, EphyBookmarkProperties, adress_entry); - gtk_widget_class_bind_template_child (widget_class, EphyBookmarkProperties, topics_label); - gtk_widget_class_bind_template_child (widget_class, EphyBookmarkProperties, topics_expander); - gtk_widget_class_bind_template_child (widget_class, EphyBookmarkProperties, topics_tree_view); - gtk_widget_class_bind_template_child (widget_class, EphyBookmarkProperties, topics_scrolled_window); - gtk_widget_class_bind_template_child (widget_class, EphyBookmarkProperties, warning_label); - - gtk_widget_class_bind_template_callback (widget_class, title_entry_changed_cb); - gtk_widget_class_bind_template_callback (widget_class, location_entry_changed_cb); - gtk_widget_class_bind_template_callback (widget_class, ephy_bookmark_properties_response_cb); - gtk_widget_class_bind_template_callback (widget_class, ephy_bookmark_properties_destroy_cb); -} - -/* public API */ - -GtkWidget * -ephy_bookmark_properties_new (EphyBookmarks *bookmarks, - EphyNode *bookmark, - gboolean creating) -{ - g_assert (bookmarks != NULL); - - return GTK_WIDGET (g_object_new (EPHY_TYPE_BOOKMARK_PROPERTIES, - "bookmarks", bookmarks, - "bookmark", bookmark, - "creating", creating, - "use-header-bar", TRUE, - NULL)); -} - -EphyNode * -ephy_bookmark_properties_get_node (EphyBookmarkProperties *properties) -{ - return properties->bookmark; -} diff --git a/src/bookmarks/ephy-bookmark-properties.h b/src/bookmarks/ephy-bookmark-properties.h deleted file mode 100644 index 63328c20a..000000000 --- a/src/bookmarks/ephy-bookmark-properties.h +++ /dev/null @@ -1,38 +0,0 @@ -/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* - * Copyright © 2002 Marco Pesenti Gritti <mpeseng@tin.it> - * Copyright © 2005, 2006 Peter A. Harvey - * Copyright © 2006 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 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, see <http://www.gnu.org/licenses/>. - */ - -#pragma once - -#include "ephy-bookmarks.h" - -#include <gtk/gtk.h> - -G_BEGIN_DECLS - -#define EPHY_TYPE_BOOKMARK_PROPERTIES (ephy_bookmark_properties_get_type ()) -G_DECLARE_FINAL_TYPE (EphyBookmarkProperties, ephy_bookmark_properties, EPHY, BOOKMARK_PROPERTIES, GtkDialog); - -GtkWidget *ephy_bookmark_properties_new (EphyBookmarks *bookmarks, - EphyNode *bookmark, - gboolean creating); - -EphyNode *ephy_bookmark_properties_get_node (EphyBookmarkProperties *properties); - -G_END_DECLS diff --git a/src/bookmarks/ephy-bookmarks-ui.c b/src/bookmarks/ephy-bookmarks-ui.c index 5e61d178b..e53e702ff 100644 --- a/src/bookmarks/ephy-bookmarks-ui.c +++ b/src/bookmarks/ephy-bookmarks-ui.c @@ -22,7 +22,6 @@ #include "ephy-bookmark-action-group.h" #include "ephy-bookmark-action.h" -#include "ephy-bookmark-properties.h" #include "ephy-bookmarks.h" #include "ephy-debug.h" #include "ephy-dnd.h" @@ -55,8 +54,6 @@ enum { RESPONSE_NEW_BOOKMARK = 2 }; -static GHashTable *properties_dialogs = 0; - void ephy_bookmarks_ui_attach_window (EphyWindow *window) { @@ -108,78 +105,23 @@ ephy_bookmarks_ui_detach_window (EphyWindow *window) g_object_set_data (G_OBJECT (window), BM_WINDOW_DATA_KEY, 0); } -static void -properties_dialog_destroy_cb (EphyBookmarkProperties *dialog, - EphyNode *bookmark) -{ - g_hash_table_remove (properties_dialogs, bookmark); -} - void ephy_bookmarks_ui_add_bookmark (GtkWindow *parent, const char *location, const char *title) { - EphyBookmarks *bookmarks; - EphyNode *bookmark; - GtkWidget *dialog; - if (g_settings_get_boolean (EPHY_SETTINGS_LOCKDOWN, EPHY_PREFS_LOCKDOWN_BOOKMARK_EDITING)) return; - - bookmarks = ephy_shell_get_bookmarks (ephy_shell_get_default ()); - bookmark = ephy_bookmarks_add (bookmarks, title, location); - - if (properties_dialogs == 0) { - properties_dialogs = g_hash_table_new (g_direct_hash, g_direct_equal); - } - - dialog = ephy_bookmark_properties_new (bookmarks, bookmark, TRUE); - - g_assert (parent != NULL); - - gtk_window_group_add_window (ephy_gui_ensure_window_group (parent), - GTK_WINDOW (dialog)); - gtk_window_set_transient_for (GTK_WINDOW (dialog), parent); - - g_signal_connect (dialog, "destroy", - G_CALLBACK (properties_dialog_destroy_cb), bookmark); - g_hash_table_insert (properties_dialogs, - bookmark, dialog); - - gtk_window_present_with_time (GTK_WINDOW (dialog), - gtk_get_current_event_time ()); } void ephy_bookmarks_ui_show_bookmark (GtkWindow *parent, EphyNode *bookmark) { EphyBookmarks *bookmarks; - GtkWidget *dialog; bookmarks = ephy_shell_get_bookmarks (ephy_shell_get_default ()); g_return_if_fail (EPHY_IS_BOOKMARKS (bookmarks)); g_return_if_fail (EPHY_IS_NODE (bookmark)); - - if (properties_dialogs == 0) { - properties_dialogs = g_hash_table_new (g_direct_hash, g_direct_equal); - } - - dialog = g_hash_table_lookup (properties_dialogs, bookmark); - - if (dialog == NULL) { - dialog = ephy_bookmark_properties_new (bookmarks, bookmark, FALSE); - - g_signal_connect (dialog, "destroy", - G_CALLBACK (properties_dialog_destroy_cb), bookmark); - g_hash_table_insert (properties_dialogs, - bookmark, dialog); - } - - gtk_window_set_transient_for (GTK_WINDOW (dialog), parent); - - gtk_window_present_with_time (GTK_WINDOW (dialog), - gtk_get_current_event_time ()); } diff --git a/src/bookmarks/ephy-bookmarks.c b/src/bookmarks/ephy-bookmarks.c index ad083e221..26ea6de92 100644 --- a/src/bookmarks/ephy-bookmarks.c +++ b/src/bookmarks/ephy-bookmarks.c @@ -20,7 +20,6 @@ #include "config.h" #include "ephy-bookmarks.h" -#include "ephy-bookmark-properties.h" #include "ephy-bookmarks-type-builtins.h" #include "ephy-debug.h" #include "ephy-embed-shell.h" |