summaryrefslogtreecommitdiff
path: root/lib/widgets
diff options
context:
space:
mode:
authorMichael Catanzaro <mcatanzaro@igalia.com>2016-03-21 23:13:34 -0500
committerMichael Catanzaro <mcatanzaro@igalia.com>2016-03-29 13:03:13 -0500
commit9ccb9da9eb9601c66e615d7a4a44c747832ddac1 (patch)
tree3b7f694c37af6e77e264bf9ded228f1a43aa7516 /lib/widgets
parent5a5e0d7cf463c14f4769de4e9a3ae9e8b38d54b4 (diff)
downloadepiphany-9ccb9da9eb9601c66e615d7a4a44c747832ddac1.tar.gz
Uncrustify
For a better future. Apologies when your 'git blame' resolves to this. I'm actually really impressed how well uncrustify works. This required only a little one-time manual work to avoid extra space in 'else {'. This breaks function prototype alignment, but we should get rid of most of those anyway. We decided to start aligning function parameters, like other GNOME applications. It looks nicer this way, and I couldn't teach uncrustify the previous Epiphany style.
Diffstat (limited to 'lib/widgets')
-rw-r--r--lib/widgets/ephy-certificate-dialog.c106
-rw-r--r--lib/widgets/ephy-download-widget.c135
-rw-r--r--lib/widgets/ephy-downloads-popover.c3
-rw-r--r--lib/widgets/ephy-downloads-progress-icon.c3
-rw-r--r--lib/widgets/ephy-file-chooser.c343
-rw-r--r--lib/widgets/ephy-location-entry.c2062
-rw-r--r--lib/widgets/ephy-middle-clickable-button.c11
-rw-r--r--lib/widgets/ephy-node-view.c2657
-rw-r--r--lib/widgets/ephy-security-popover.c130
-rw-r--r--lib/widgets/ephy-tree-model-node.c653
-rw-r--r--lib/widgets/ephy-tree-model-sort.c164
-rw-r--r--lib/widgets/ephy-zoom-action.c245
-rw-r--r--lib/widgets/nautilus-floating-bar.c658
13 files changed, 3480 insertions, 3690 deletions
diff --git a/lib/widgets/ephy-certificate-dialog.c b/lib/widgets/ephy-certificate-dialog.c
index 5e038b8a5..ab21ae15c 100644
--- a/lib/widgets/ephy-certificate-dialog.c
+++ b/lib/widgets/ephy-certificate-dialog.c
@@ -32,8 +32,7 @@
* #EphyCertificateDialog shows information about SSL certificates.
*/
-enum
-{
+enum {
PROP_0,
PROP_ADDRESS,
PROP_CERTIFICATE,
@@ -44,8 +43,7 @@ enum
static GParamSpec *obj_properties[LAST_PROP];
-struct _EphyCertificateDialog
-{
+struct _EphyCertificateDialog {
GtkDialog parent_object;
GtkWidget *icon;
@@ -60,7 +58,7 @@ G_DEFINE_TYPE (EphyCertificateDialog, ephy_certificate_dialog, GTK_TYPE_DIALOG)
static void
ephy_certificate_dialog_set_address (EphyCertificateDialog *dialog,
- const char *address)
+ const char *address)
{
SoupURI *uri;
@@ -71,7 +69,7 @@ ephy_certificate_dialog_set_address (EphyCertificateDialog *dialog,
static void
ephy_certificate_dialog_set_certificate (EphyCertificateDialog *dialog,
- GTlsCertificate *certificate)
+ GTlsCertificate *certificate)
{
GcrCertificate *simple_certificate;
GByteArray *certificate_data;
@@ -80,7 +78,7 @@ ephy_certificate_dialog_set_certificate (EphyCertificateDialog *dialog,
g_object_get (certificate, "certificate", &certificate_data, NULL);
simple_certificate = gcr_simple_certificate_new ((const guchar *)certificate_data->data,
- certificate_data->len);
+ certificate_data->len);
g_byte_array_unref (certificate_data);
certificate_widget = GTK_WIDGET (gcr_certificate_widget_new (simple_certificate));
@@ -126,9 +124,9 @@ get_error_messages_from_tls_errors (GTlsCertificateFlags tls_errors)
for (i = 0; i < errors->len; i++) {
g_string_append_printf (message, "• %s",
- (char *)g_ptr_array_index (errors, i));
+ (char *)g_ptr_array_index (errors, i));
if (i < errors->len - 1)
- g_string_append_c (message, '\n');
+ g_string_append_c (message, '\n');
}
retval = g_string_free (message, FALSE);
@@ -157,9 +155,9 @@ ephy_certificate_dialog_constructed (GObject *object)
}
markup = g_strdup_printf ("<span weight=\"bold\" size=\"large\">%s</span>",
- dialog->tls_errors == 0 ?
- _("The identity of this website has been verified.") :
- _("The identity of this website has not been verified."));
+ dialog->tls_errors == 0 ?
+ _("The identity of this website has been verified.") :
+ _("The identity of this website has not been verified."));
gtk_label_set_markup (GTK_LABEL (dialog->title), markup);
g_free (markup);
@@ -169,48 +167,48 @@ ephy_certificate_dialog_constructed (GObject *object)
g_free (text);
} else {
switch (dialog->security_level) {
- case EPHY_SECURITY_LEVEL_STRONG_SECURITY:
- /* Message on certificte dialog ertificate dialog */
- gtk_label_set_text (GTK_LABEL (dialog->text), _("No problems have been detected with your connection."));
- break;
- case EPHY_SECURITY_LEVEL_MIXED_CONTENT:
- gtk_label_set_text (GTK_LABEL (dialog->text), _("This certificate is valid. However, "
- "resources on this page were sent insecurely."));
- break;
- case EPHY_SECURITY_LEVEL_TO_BE_DETERMINED:
- case EPHY_SECURITY_LEVEL_NO_SECURITY:
- case EPHY_SECURITY_LEVEL_UNACCEPTABLE_CERTIFICATE:
- case EPHY_SECURITY_LEVEL_LOCAL_PAGE:
- default:
- g_assert_not_reached ();
+ case EPHY_SECURITY_LEVEL_STRONG_SECURITY:
+ /* Message on certificte dialog ertificate dialog */
+ gtk_label_set_text (GTK_LABEL (dialog->text), _("No problems have been detected with your connection."));
+ break;
+ case EPHY_SECURITY_LEVEL_MIXED_CONTENT:
+ gtk_label_set_text (GTK_LABEL (dialog->text), _("This certificate is valid. However, "
+ "resources on this page were sent insecurely."));
+ break;
+ case EPHY_SECURITY_LEVEL_TO_BE_DETERMINED:
+ case EPHY_SECURITY_LEVEL_NO_SECURITY:
+ case EPHY_SECURITY_LEVEL_UNACCEPTABLE_CERTIFICATE:
+ case EPHY_SECURITY_LEVEL_LOCAL_PAGE:
+ default:
+ g_assert_not_reached ();
}
}
gtk_widget_show (dialog->text);
}
static void
-ephy_certificate_dialog_set_property (GObject *object,
- guint prop_id,
+ephy_certificate_dialog_set_property (GObject *object,
+ guint prop_id,
const GValue *value,
- GParamSpec *pspec)
+ GParamSpec *pspec)
{
EphyCertificateDialog *dialog = EPHY_CERTIFICATE_DIALOG (object);
switch (prop_id) {
- case PROP_ADDRESS:
- ephy_certificate_dialog_set_address (dialog, g_value_get_string (value));
- break;
- case PROP_CERTIFICATE:
- ephy_certificate_dialog_set_certificate (dialog, g_value_get_object (value));
- break;
- case PROP_SECURITY_LEVEL:
- dialog->security_level = g_value_get_enum (value);
- break;
- case PROP_TLS_ERRORS:
- dialog->tls_errors = g_value_get_flags (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ case PROP_ADDRESS:
+ ephy_certificate_dialog_set_address (dialog, g_value_get_string (value));
+ break;
+ case PROP_CERTIFICATE:
+ ephy_certificate_dialog_set_certificate (dialog, g_value_get_object (value));
+ break;
+ case PROP_SECURITY_LEVEL:
+ dialog->security_level = g_value_get_enum (value);
+ break;
+ case PROP_TLS_ERRORS:
+ dialog->tls_errors = g_value_get_flags (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
@@ -299,7 +297,7 @@ ephy_certificate_dialog_init (EphyCertificateDialog *dialog)
dialog->title = gtk_label_new (NULL);
gtk_label_set_use_markup (GTK_LABEL (dialog->title), TRUE);
- gtk_label_set_line_wrap (GTK_LABEL (dialog->title), TRUE);
+ gtk_label_set_line_wrap (GTK_LABEL (dialog->title), TRUE);
gtk_label_set_selectable (GTK_LABEL (dialog->title), TRUE);
gtk_widget_set_halign (dialog->title, GTK_ALIGN_START);
gtk_widget_set_valign (dialog->title, GTK_ALIGN_CENTER);
@@ -310,7 +308,7 @@ ephy_certificate_dialog_init (EphyCertificateDialog *dialog)
gtk_widget_show (dialog->title);
dialog->text = gtk_label_new (NULL);
- gtk_label_set_line_wrap (GTK_LABEL (dialog->text), TRUE);
+ gtk_label_set_line_wrap (GTK_LABEL (dialog->text), TRUE);
gtk_label_set_selectable (GTK_LABEL (dialog->text), TRUE);
gtk_widget_set_halign (dialog->text, GTK_ALIGN_START);
gtk_widget_set_valign (dialog->text, GTK_ALIGN_START);
@@ -326,11 +324,11 @@ ephy_certificate_dialog_init (EphyCertificateDialog *dialog)
}
GtkWidget *
-ephy_certificate_dialog_new (GtkWindow *parent,
- const char *address,
- GTlsCertificate *certificate,
+ephy_certificate_dialog_new (GtkWindow *parent,
+ const char *address,
+ GTlsCertificate *certificate,
GTlsCertificateFlags tls_errors,
- EphySecurityLevel security_level)
+ EphySecurityLevel security_level)
{
GtkWidget *dialog;
@@ -338,13 +336,13 @@ ephy_certificate_dialog_new (GtkWindow *parent,
g_return_val_if_fail (G_IS_TLS_CERTIFICATE (certificate), NULL);
dialog = GTK_WIDGET (g_object_new (EPHY_TYPE_CERTIFICATE_DIALOG,
- "address", address,
- "certificate", certificate,
- "security-level", security_level,
- "tls-errors", tls_errors,
+ "address", address,
+ "certificate", certificate,
+ "security-level", security_level,
+ "tls-errors", tls_errors,
"modal", TRUE,
"use-header-bar", TRUE,
- NULL));
+ NULL));
if (parent)
gtk_window_set_transient_for (GTK_WINDOW (dialog), parent);
diff --git a/lib/widgets/ephy-download-widget.c b/lib/widgets/ephy-download-widget.c
index ed11528e2..5ad18cdf6 100644
--- a/lib/widgets/ephy-download-widget.c
+++ b/lib/widgets/ephy-download-widget.c
@@ -31,8 +31,7 @@
#include <glib/gi18n.h>
#include <webkit2/webkit2.h>
-struct _EphyDownloadWidget
-{
+struct _EphyDownloadWidget {
GtkGrid parent_instance;
EphyDownload *download;
@@ -46,8 +45,7 @@ struct _EphyDownloadWidget
G_DEFINE_TYPE (EphyDownloadWidget, ephy_download_widget, GTK_TYPE_GRID)
-enum
-{
+enum {
PROP_0,
PROP_DOWNLOAD,
LAST_PROP
@@ -79,41 +77,30 @@ get_destination_basename_from_download (EphyDownload *ephy_download)
static gchar *
duration_to_string (guint seconds)
{
- if (seconds < 60)
- {
- return g_strdup_printf (ngettext ("%d second left",
- "%d seconds left", seconds), seconds);
- }
- else if (seconds < (60 * 60))
- {
- seconds /= 60;
- return g_strdup_printf (ngettext ("%d minute left",
- "%d minutes left", seconds), seconds);
- }
- else if (seconds < (60 * 60 * 24))
- {
- seconds /= 60 * 60;
- return g_strdup_printf (ngettext ("%d hour left",
- "%d hours left", seconds), seconds);
- }
- else if (seconds < (60 * 60 * 24 * 7))
- {
- seconds /= 60 * 60 * 24;
- return g_strdup_printf (ngettext ("%d day left",
- "%d days left", seconds), seconds);
- }
- else if (seconds < (60 * 60 * 24 * 30))
- {
- seconds /= 60 * 60 * 24 * 7;
- return g_strdup_printf (ngettext ("%d week left",
- "%d weeks left", seconds), seconds);
- }
- else
- {
- seconds /= 60 * 60 * 24 * 30;
- return g_strdup_printf (ngettext ("%d month left",
- "%d months left", seconds), seconds);
- }
+ if (seconds < 60) {
+ return g_strdup_printf (ngettext ("%d second left",
+ "%d seconds left", seconds), seconds);
+ } else if (seconds < (60 * 60)) {
+ seconds /= 60;
+ return g_strdup_printf (ngettext ("%d minute left",
+ "%d minutes left", seconds), seconds);
+ } else if (seconds < (60 * 60 * 24)) {
+ seconds /= 60 * 60;
+ return g_strdup_printf (ngettext ("%d hour left",
+ "%d hours left", seconds), seconds);
+ } else if (seconds < (60 * 60 * 24 * 7)) {
+ seconds /= 60 * 60 * 24;
+ return g_strdup_printf (ngettext ("%d day left",
+ "%d days left", seconds), seconds);
+ } else if (seconds < (60 * 60 * 24 * 30)) {
+ seconds /= 60 * 60 * 24 * 7;
+ return g_strdup_printf (ngettext ("%d week left",
+ "%d weeks left", seconds), seconds);
+ } else {
+ seconds /= 60 * 60 * 24 * 30;
+ return g_strdup_printf (ngettext ("%d month left",
+ "%d months left", seconds), seconds);
+ }
}
static gdouble
@@ -171,7 +158,7 @@ update_download_destination (EphyDownloadWidget *widget)
static void
update_status_label (EphyDownloadWidget *widget,
- const char *download_label)
+ const char *download_label)
{
char *markup;
@@ -181,8 +168,8 @@ update_status_label (EphyDownloadWidget *widget,
}
static void
-download_progress_cb (WebKitDownload *download,
- GParamSpec *pspec,
+download_progress_cb (WebKitDownload *download,
+ GParamSpec *pspec,
EphyDownloadWidget *widget)
{
gdouble progress;
@@ -200,24 +187,24 @@ download_progress_cb (WebKitDownload *download,
received_length = webkit_download_get_received_data_length (download);
if (content_length > 0 && received_length > 0) {
- gdouble time;
- char *remaining;
- char *received;
- char *total;
-
- received = g_format_size (received_length);
- total = g_format_size (content_length);
-
- time = get_remaining_time (content_length, received_length,
- webkit_download_get_elapsed_time (download));
- remaining = duration_to_string ((guint)time);
- download_label = g_strdup_printf ("%s / %s — %s", received, total, remaining);
- g_free (received);
- g_free (total);
- g_free (remaining);
-
- gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (widget->progress),
- progress);
+ gdouble time;
+ char *remaining;
+ char *received;
+ char *total;
+
+ received = g_format_size (received_length);
+ total = g_format_size (content_length);
+
+ time = get_remaining_time (content_length, received_length,
+ webkit_download_get_elapsed_time (download));
+ remaining = duration_to_string ((guint)time);
+ download_label = g_strdup_printf ("%s / %s — %s", received, total, remaining);
+ g_free (received);
+ g_free (total);
+ g_free (remaining);
+
+ gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (widget->progress),
+ progress);
} else if (received_length > 0) {
download_label = g_format_size (received_length);
gtk_progress_bar_pulse (GTK_PROGRESS_BAR (widget->progress));
@@ -230,7 +217,7 @@ download_progress_cb (WebKitDownload *download,
}
static void
-download_finished_cb (EphyDownload *download,
+download_finished_cb (EphyDownload *download,
EphyDownloadWidget *widget)
{
gtk_widget_hide (widget->progress);
@@ -241,8 +228,8 @@ download_finished_cb (EphyDownload *download,
}
static void
-download_failed_cb (EphyDownload *download,
- GError *error,
+download_failed_cb (EphyDownload *download,
+ GError *error,
EphyDownloadWidget *widget)
{
char *error_msg;
@@ -260,8 +247,8 @@ download_failed_cb (EphyDownload *download,
}
static void
-download_content_type_changed_cb (EphyDownload *download,
- GParamSpec *spec,
+download_content_type_changed_cb (EphyDownload *download,
+ GParamSpec *spec,
EphyDownloadWidget *widget)
{
update_download_icon (widget);
@@ -294,8 +281,8 @@ widget_action_button_clicked_cb (EphyDownloadWidget *widget)
}
static void
-download_destination_changed_cb (WebKitDownload *download,
- GParamSpec *pspec,
+download_destination_changed_cb (WebKitDownload *download,
+ GParamSpec *pspec,
EphyDownloadWidget *widget)
{
update_download_destination (widget);
@@ -402,7 +389,7 @@ ephy_download_widget_constructed (GObject *object)
gtk_progress_bar_set_pulse_step (GTK_PROGRESS_BAR (widget->progress), 0.05);
gtk_grid_attach (GTK_GRID (widget), widget->progress, 0, 1, 2, 1);
if (ephy_download_is_active (widget->download))
- gtk_widget_show (widget->progress);
+ gtk_widget_show (widget->progress);
widget->status = gtk_label_new (NULL);
gtk_widget_set_valign (widget->status, GTK_ALIGN_CENTER);
@@ -411,15 +398,15 @@ ephy_download_widget_constructed (GObject *object)
gtk_label_set_max_width_chars (GTK_LABEL (widget->status), 30);
gtk_label_set_ellipsize (GTK_LABEL (widget->status), PANGO_ELLIPSIZE_END);
if (ephy_download_failed (widget->download, &error)) {
- char *error_msg;
+ char *error_msg;
- error_msg = g_strdup_printf (_("Error downloading: %s"), error->message);
- update_status_label (widget, error_msg);
- g_free (error_msg);
+ error_msg = g_strdup_printf (_("Error downloading: %s"), error->message);
+ update_status_label (widget, error_msg);
+ g_free (error_msg);
} else if (ephy_download_succeeded (widget->download)) {
- update_status_label (widget, _("Finished"));
+ update_status_label (widget, _("Finished"));
} else {
- update_status_label (widget, _("Starting…"));
+ update_status_label (widget, _("Starting…"));
}
gtk_grid_attach (GTK_GRID (widget), widget->status, 0, 2, 2, 1);
gtk_widget_show (widget->status);
diff --git a/lib/widgets/ephy-downloads-popover.c b/lib/widgets/ephy-downloads-popover.c
index 65d151657..a0f1e4ece 100644
--- a/lib/widgets/ephy-downloads-popover.c
+++ b/lib/widgets/ephy-downloads-popover.c
@@ -26,8 +26,7 @@
#include <glib/gi18n.h>
-struct _EphyDownloadsPopover
-{
+struct _EphyDownloadsPopover {
GtkPopover parent_instance;
GtkWidget *downloads_box;
diff --git a/lib/widgets/ephy-downloads-progress-icon.c b/lib/widgets/ephy-downloads-progress-icon.c
index 05c87c89d..0957c5196 100644
--- a/lib/widgets/ephy-downloads-progress-icon.c
+++ b/lib/widgets/ephy-downloads-progress-icon.c
@@ -23,8 +23,7 @@
#include "ephy-downloads-manager.h"
#include "ephy-embed-shell.h"
-struct _EphyDownloadsProgressIcon
-{
+struct _EphyDownloadsProgressIcon {
GtkDrawingArea parent_instance;
GtkWidget *downloads_box;
diff --git a/lib/widgets/ephy-file-chooser.c b/lib/widgets/ephy-file-chooser.c
index add180613..b34cc940c 100644
--- a/lib/widgets/ephy-file-chooser.c
+++ b/lib/widgets/ephy-file-chooser.c
@@ -28,15 +28,14 @@
#include <gtk/gtk.h>
#include <glib/gi18n.h>
-static void ephy_file_chooser_image_preview (GtkFileChooser *file_chooser,
- gpointer user_data);
+static void ephy_file_chooser_image_preview (GtkFileChooser *file_chooser,
+ gpointer user_data);
#define PREVIEW_WIDTH 150
#define PREVIEW_HEIGHT 150
-struct _EphyFileChooser
-{
- GtkFileChooserDialog parent_instance;
+struct _EphyFileChooser {
+ GtkFileChooserDialog parent_instance;
};
G_DEFINE_TYPE (EphyFileChooser, ephy_file_chooser, GTK_TYPE_FILE_CHOOSER_DIALOG)
@@ -47,215 +46,207 @@ ephy_file_chooser_init (EphyFileChooser *dialog)
}
static GObject *
-ephy_file_chooser_constructor (GType type,
- guint n_construct_properties,
- GObjectConstructParam *construct_params)
+ephy_file_chooser_constructor (GType type,
+ guint n_construct_properties,
+ GObjectConstructParam *construct_params)
{
- GObject *object;
- char *downloads_dir;
+ GObject *object;
+ char *downloads_dir;
- object = G_OBJECT_CLASS (ephy_file_chooser_parent_class)->constructor (type, n_construct_properties,
- construct_params);
+ object = G_OBJECT_CLASS (ephy_file_chooser_parent_class)->constructor (type, n_construct_properties,
+ construct_params);
- downloads_dir = ephy_file_get_downloads_dir ();
- gtk_file_chooser_add_shortcut_folder
- (GTK_FILE_CHOOSER (object), downloads_dir, NULL);
- g_free (downloads_dir);
+ downloads_dir = ephy_file_get_downloads_dir ();
+ gtk_file_chooser_add_shortcut_folder
+ (GTK_FILE_CHOOSER (object), downloads_dir, NULL);
+ g_free (downloads_dir);
- return object;
+ return object;
}
GtkFileFilter *
ephy_file_chooser_add_pattern_filter (EphyFileChooser *dialog,
- const char *title,
- const char *first_pattern,
- ...)
+ const char *title,
+ const char *first_pattern,
+ ...)
{
- GtkFileFilter *filth;
- va_list args;
- const char *pattern;
+ GtkFileFilter *filth;
+ va_list args;
+ const char *pattern;
- filth = gtk_file_filter_new ();
+ filth = gtk_file_filter_new ();
- va_start (args, first_pattern);
+ va_start (args, first_pattern);
- pattern = first_pattern;
- while (pattern != NULL)
- {
- gtk_file_filter_add_pattern (filth, pattern);
- pattern = va_arg (args, const char *);
- }
- va_end (args);
+ pattern = first_pattern;
+ while (pattern != NULL) {
+ gtk_file_filter_add_pattern (filth, pattern);
+ pattern = va_arg (args, const char *);
+ }
+ va_end (args);
- gtk_file_filter_set_name (filth, title);
+ gtk_file_filter_set_name (filth, title);
- gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filth);
+ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filth);
- return filth;
+ return filth;
}
GtkFileFilter *
ephy_file_chooser_add_mime_filter (EphyFileChooser *dialog,
- const char *title,
- const char *first_mimetype,
- ...)
+ const char *title,
+ const char *first_mimetype,
+ ...)
{
- GtkFileFilter *filth;
- va_list args;
- const char *mimetype;
+ GtkFileFilter *filth;
+ va_list args;
+ const char *mimetype;
- filth = gtk_file_filter_new ();
+ filth = gtk_file_filter_new ();
- va_start (args, first_mimetype);
+ va_start (args, first_mimetype);
- mimetype = first_mimetype;
- while (mimetype != NULL)
- {
- gtk_file_filter_add_mime_type (filth, mimetype);
- mimetype = va_arg (args, const char *);
- }
- va_end (args);
+ mimetype = first_mimetype;
+ while (mimetype != NULL) {
+ gtk_file_filter_add_mime_type (filth, mimetype);
+ mimetype = va_arg (args, const char *);
+ }
+ va_end (args);
- gtk_file_filter_set_name (filth, title);
+ gtk_file_filter_set_name (filth, title);
- gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filth);
+ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filth);
- return filth;
+ return filth;
}
static void
ephy_file_chooser_class_init (EphyFileChooserClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->constructor = ephy_file_chooser_constructor;
+ object_class->constructor = ephy_file_chooser_constructor;
}
static void
-ephy_file_chooser_image_preview (GtkFileChooser *file_chooser,
- gpointer user_data)
+ephy_file_chooser_image_preview (GtkFileChooser *file_chooser,
+ gpointer user_data)
{
- char *filename;
- GtkWidget *preview;
- GdkPixbuf *pixbuf;
- gboolean have_preview;
-
- pixbuf = NULL;
- preview = GTK_WIDGET (user_data);
- filename = gtk_file_chooser_get_preview_filename (file_chooser);
-
- if (filename)
- pixbuf = gdk_pixbuf_new_from_file_at_size (filename,
- PREVIEW_WIDTH, PREVIEW_HEIGHT, NULL);
- g_free (filename);
-
- have_preview = (pixbuf != NULL);
- gtk_image_set_from_pixbuf (GTK_IMAGE (preview), pixbuf);
-
- if (pixbuf)
- g_object_unref (pixbuf);
-
- gtk_file_chooser_set_preview_widget_active (file_chooser, have_preview);
-
+ char *filename;
+ GtkWidget *preview;
+ GdkPixbuf *pixbuf;
+ gboolean have_preview;
+
+ pixbuf = NULL;
+ preview = GTK_WIDGET (user_data);
+ filename = gtk_file_chooser_get_preview_filename (file_chooser);
+
+ if (filename)
+ pixbuf = gdk_pixbuf_new_from_file_at_size (filename,
+ PREVIEW_WIDTH, PREVIEW_HEIGHT, NULL);
+ g_free (filename);
+
+ have_preview = (pixbuf != NULL);
+ gtk_image_set_from_pixbuf (GTK_IMAGE (preview), pixbuf);
+
+ if (pixbuf)
+ g_object_unref (pixbuf);
+
+ gtk_file_chooser_set_preview_widget_active (file_chooser, have_preview);
}
-EphyFileChooser *
-ephy_file_chooser_new (const char *title,
- GtkWidget *parent,
- GtkFileChooserAction action,
- EphyFileFilterDefault default_filter)
+EphyFileChooser *
+ephy_file_chooser_new (const char *title,
+ GtkWidget *parent,
+ GtkFileChooserAction action,
+ EphyFileFilterDefault default_filter)
{
- EphyFileChooser *dialog;
- GtkFileFilter *filter[EPHY_FILE_FILTER_LAST];
- GtkWidget *preview;
-
- g_return_val_if_fail (default_filter >= 0 && default_filter <= EPHY_FILE_FILTER_LAST, NULL);
-
- dialog = EPHY_FILE_CHOOSER (g_object_new (EPHY_TYPE_FILE_CHOOSER,
- "title", title,
- "action", action,
- NULL));
-
- if (action == GTK_FILE_CHOOSER_ACTION_OPEN ||
- action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER ||
- action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)
- {
- gtk_dialog_add_buttons (GTK_DIALOG (dialog),
- _("_Cancel"), GTK_RESPONSE_CANCEL,
- _("_Open"), GTK_RESPONSE_ACCEPT,
- NULL);
- gtk_dialog_set_default_response (GTK_DIALOG (dialog),
- GTK_RESPONSE_ACCEPT);
- }
- else if (action == GTK_FILE_CHOOSER_ACTION_SAVE)
- {
- gtk_dialog_add_buttons (GTK_DIALOG (dialog),
- _("_Cancel"), GTK_RESPONSE_CANCEL,
- _("_Save"), GTK_RESPONSE_ACCEPT,
- NULL);
- gtk_dialog_set_default_response (GTK_DIALOG (dialog),
- GTK_RESPONSE_ACCEPT);
- }
-
- preview = gtk_image_new ();
- gtk_file_chooser_set_preview_widget (GTK_FILE_CHOOSER (dialog), preview);
- gtk_file_chooser_set_preview_widget_active (GTK_FILE_CHOOSER (dialog), FALSE);
- g_signal_connect (dialog, "update-preview", G_CALLBACK (ephy_file_chooser_image_preview), preview);
-
- if (default_filter != EPHY_FILE_FILTER_NONE)
- {
- filter[EPHY_FILE_FILTER_ALL_SUPPORTED] =
- ephy_file_chooser_add_mime_filter
- (dialog,
- _("All supported types"),
- "text/html",
- "application/xhtml+xml",
- "text/xml",
- "message/rfc822", /* MHTML */
- "multipart/related", /* MHTML */
- "application/x-mimearchive", /* MHTML */
- "image/png",
- "image/jpeg",
- "image/gif",
- NULL);
-
- filter[EPHY_FILE_FILTER_WEBPAGES] =
- ephy_file_chooser_add_mime_filter
- (dialog, _("Web pages"),
- "text/html",
- "application/xhtml+xml",
- "text/xml",
- "message/rfc822", /* MHTML */
- "multipart/related", /* MHTML */
- "application/x-mimearchive", /* MHTML */
- NULL);
-
- filter[EPHY_FILE_FILTER_IMAGES] =
- ephy_file_chooser_add_mime_filter
- (dialog, _("Images"),
- "image/png",
- "image/jpeg",
- "image/gif",
- NULL);
-
- filter[EPHY_FILE_FILTER_ALL] =
- ephy_file_chooser_add_pattern_filter
- (dialog, _("All files"), "*", NULL);
-
- gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (dialog),
- filter[default_filter]);
- }
-
- if (parent != NULL)
- {
- gtk_window_set_transient_for (GTK_WINDOW (dialog),
- GTK_WINDOW (parent));
- gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
- gtk_window_group_add_window (ephy_gui_ensure_window_group (GTK_WINDOW (parent)),
- GTK_WINDOW (dialog));
- gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog), TRUE);
- }
-
- return dialog;
+ EphyFileChooser *dialog;
+ GtkFileFilter *filter[EPHY_FILE_FILTER_LAST];
+ GtkWidget *preview;
+
+ g_return_val_if_fail (default_filter >= 0 && default_filter <= EPHY_FILE_FILTER_LAST, NULL);
+
+ dialog = EPHY_FILE_CHOOSER (g_object_new (EPHY_TYPE_FILE_CHOOSER,
+ "title", title,
+ "action", action,
+ NULL));
+
+ if (action == GTK_FILE_CHOOSER_ACTION_OPEN ||
+ action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER ||
+ action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER) {
+ gtk_dialog_add_buttons (GTK_DIALOG (dialog),
+ _("_Cancel"), GTK_RESPONSE_CANCEL,
+ _("_Open"), GTK_RESPONSE_ACCEPT,
+ NULL);
+ gtk_dialog_set_default_response (GTK_DIALOG (dialog),
+ GTK_RESPONSE_ACCEPT);
+ } else if (action == GTK_FILE_CHOOSER_ACTION_SAVE) {
+ gtk_dialog_add_buttons (GTK_DIALOG (dialog),
+ _("_Cancel"), GTK_RESPONSE_CANCEL,
+ _("_Save"), GTK_RESPONSE_ACCEPT,
+ NULL);
+ gtk_dialog_set_default_response (GTK_DIALOG (dialog),
+ GTK_RESPONSE_ACCEPT);
+ }
+
+ preview = gtk_image_new ();
+ gtk_file_chooser_set_preview_widget (GTK_FILE_CHOOSER (dialog), preview);
+ gtk_file_chooser_set_preview_widget_active (GTK_FILE_CHOOSER (dialog), FALSE);
+ g_signal_connect (dialog, "update-preview", G_CALLBACK (ephy_file_chooser_image_preview), preview);
+
+ if (default_filter != EPHY_FILE_FILTER_NONE) {
+ filter[EPHY_FILE_FILTER_ALL_SUPPORTED] =
+ ephy_file_chooser_add_mime_filter
+ (dialog,
+ _("All supported types"),
+ "text/html",
+ "application/xhtml+xml",
+ "text/xml",
+ "message/rfc822", /* MHTML */
+ "multipart/related", /* MHTML */
+ "application/x-mimearchive", /* MHTML */
+ "image/png",
+ "image/jpeg",
+ "image/gif",
+ NULL);
+
+ filter[EPHY_FILE_FILTER_WEBPAGES] =
+ ephy_file_chooser_add_mime_filter
+ (dialog, _("Web pages"),
+ "text/html",
+ "application/xhtml+xml",
+ "text/xml",
+ "message/rfc822", /* MHTML */
+ "multipart/related", /* MHTML */
+ "application/x-mimearchive", /* MHTML */
+ NULL);
+
+ filter[EPHY_FILE_FILTER_IMAGES] =
+ ephy_file_chooser_add_mime_filter
+ (dialog, _("Images"),
+ "image/png",
+ "image/jpeg",
+ "image/gif",
+ NULL);
+
+ filter[EPHY_FILE_FILTER_ALL] =
+ ephy_file_chooser_add_pattern_filter
+ (dialog, _("All files"), "*", NULL);
+
+ gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (dialog),
+ filter[default_filter]);
+ }
+
+ if (parent != NULL) {
+ gtk_window_set_transient_for (GTK_WINDOW (dialog),
+ GTK_WINDOW (parent));
+ gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
+ gtk_window_group_add_window (ephy_gui_ensure_window_group (GTK_WINDOW (parent)),
+ GTK_WINDOW (dialog));
+ gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog), TRUE);
+ }
+
+ return dialog;
}
diff --git a/lib/widgets/ephy-location-entry.c b/lib/widgets/ephy-location-entry.c
index ff77c0af9..8ddeb15fd 100644
--- a/lib/widgets/ephy-location-entry.c
+++ b/lib/widgets/ephy-location-entry.c
@@ -50,1037 +50,1003 @@
* #EphyLocationEntry implements the location bar in the main Epiphany window.
*/
-struct _EphyLocationEntry
-{
- GtkEntry parent_instance;
+struct _EphyLocationEntry {
+ GtkEntry parent_instance;
- GdkPixbuf *favicon;
- GtkTreeModel *model;
+ GdkPixbuf *favicon;
+ GtkTreeModel *model;
- GSList *search_terms;
+ GSList *search_terms;
- char *before_completion;
- char *saved_text;
+ char *before_completion;
+ char *saved_text;
- guint text_col;
- guint action_col;
- guint keywords_col;
- guint relevance_col;
- guint url_col;
- guint extra_col;
- guint favicon_col;
+ guint text_col;
+ guint action_col;
+ guint keywords_col;
+ guint relevance_col;
+ guint url_col;
+ guint extra_col;
+ guint favicon_col;
- guint hash;
+ guint hash;
- gulong dns_prefetch_handler;
+ gulong dns_prefetch_handler;
- guint user_changed : 1;
- guint can_redo : 1;
- guint block_update : 1;
- guint original_address : 1;
- guint apply_colors : 1;
- guint needs_reset : 1;
- guint show_favicon : 1;
+ guint user_changed : 1;
+ guint can_redo : 1;
+ guint block_update : 1;
+ guint original_address : 1;
+ guint apply_colors : 1;
+ guint needs_reset : 1;
+ guint show_favicon : 1;
- GtkTargetList *drag_targets;
- GdkDragAction drag_actions;
+ GtkTargetList *drag_targets;
+ GdkDragAction drag_actions;
};
static const GtkTargetEntry url_drag_types [] =
{
- { (char *)EPHY_DND_URL_TYPE, 0, 0 },
- { (char *)EPHY_DND_URI_LIST_TYPE, 0, 1 },
- { (char *)EPHY_DND_TEXT_TYPE, 0, 2 }
+ { (char *)EPHY_DND_URL_TYPE, 0, 0 },
+ { (char *)EPHY_DND_URI_LIST_TYPE, 0, 1 },
+ { (char *)EPHY_DND_TEXT_TYPE, 0, 2 }
};
static gboolean ephy_location_entry_reset_internal (EphyLocationEntry *, gboolean);
-static void extracell_data_func (GtkCellLayout *cell_layout,
- GtkCellRenderer *cell,
- GtkTreeModel *tree_model,
- GtkTreeIter *iter,
- gpointer data);
-
-enum
-{
- PROP_0,
- PROP_LOCATION,
- PROP_FAVICON,
- PROP_SECURITY_LEVEL,
- PROP_SHOW_FAVICON,
- LAST_PROP
+static void extracell_data_func (GtkCellLayout *cell_layout,
+ GtkCellRenderer *cell,
+ GtkTreeModel *tree_model,
+ GtkTreeIter *iter,
+ gpointer data);
+
+enum {
+ PROP_0,
+ PROP_LOCATION,
+ PROP_FAVICON,
+ PROP_SECURITY_LEVEL,
+ PROP_SHOW_FAVICON,
+ LAST_PROP
};
static GParamSpec *obj_properties[LAST_PROP];
-enum signalsEnum
-{
- USER_CHANGED,
- LOCK_CLICKED,
- GET_LOCATION,
- GET_TITLE,
- LAST_SIGNAL
+enum signalsEnum {
+ USER_CHANGED,
+ LOCK_CLICKED,
+ GET_LOCATION,
+ GET_TITLE,
+ LAST_SIGNAL
};
static gint signals[LAST_SIGNAL] = { 0 };
G_DEFINE_TYPE (EphyLocationEntry, ephy_location_entry, GTK_TYPE_ENTRY)
static void
-ephy_location_entry_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+ephy_location_entry_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
- EphyLocationEntry *entry = EPHY_LOCATION_ENTRY (object);
-
- switch (prop_id)
- {
- case PROP_LOCATION:
- ephy_location_entry_set_location (entry,
- g_value_get_string (value));
- break;
- case PROP_FAVICON:
- ephy_location_entry_set_favicon (entry,
- g_value_get_object (value));
- break;
- case PROP_SECURITY_LEVEL:
- ephy_location_entry_set_security_level (entry,
- g_value_get_enum (value));
- break;
- case PROP_SHOW_FAVICON:
- ephy_location_entry_set_show_favicon (entry,
- g_value_get_boolean (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id,pspec);
- }
+ EphyLocationEntry *entry = EPHY_LOCATION_ENTRY (object);
+
+ switch (prop_id) {
+ case PROP_LOCATION:
+ ephy_location_entry_set_location (entry,
+ g_value_get_string (value));
+ break;
+ case PROP_FAVICON:
+ ephy_location_entry_set_favicon (entry,
+ g_value_get_object (value));
+ break;
+ case PROP_SECURITY_LEVEL:
+ ephy_location_entry_set_security_level (entry,
+ g_value_get_enum (value));
+ break;
+ case PROP_SHOW_FAVICON:
+ ephy_location_entry_set_show_favicon (entry,
+ g_value_get_boolean (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
}
static void
-ephy_location_entry_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+ephy_location_entry_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
{
- EphyLocationEntry *entry = EPHY_LOCATION_ENTRY (object);
-
- switch (prop_id)
- {
- case PROP_LOCATION:
- g_value_set_string (value, ephy_location_entry_get_location (entry));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id,pspec);
- }
+ EphyLocationEntry *entry = EPHY_LOCATION_ENTRY (object);
+
+ switch (prop_id) {
+ case PROP_LOCATION:
+ g_value_set_string (value, ephy_location_entry_get_location (entry));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
}
static void
ephy_location_entry_finalize (GObject *object)
{
- EphyLocationEntry *entry = EPHY_LOCATION_ENTRY (object);
+ EphyLocationEntry *entry = EPHY_LOCATION_ENTRY (object);
- g_free (entry->saved_text);
+ g_free (entry->saved_text);
- if (entry->drag_targets != NULL)
- {
- gtk_target_list_unref (entry->drag_targets);
- }
+ if (entry->drag_targets != NULL) {
+ gtk_target_list_unref (entry->drag_targets);
+ }
- if (entry->favicon != NULL)
- {
- g_object_unref (entry->favicon);
- }
+ if (entry->favicon != NULL) {
+ g_object_unref (entry->favicon);
+ }
- G_OBJECT_CLASS (ephy_location_entry_parent_class)->finalize (object);
+ G_OBJECT_CLASS (ephy_location_entry_parent_class)->finalize (object);
}
static void
-ephy_location_entry_get_preferred_width (GtkWidget *widget,
- gint *minimum_width,
- gint *natural_width)
+ephy_location_entry_get_preferred_width (GtkWidget *widget,
+ gint *minimum_width,
+ gint *natural_width)
{
- if (minimum_width)
- *minimum_width = -1;
+ if (minimum_width)
+ *minimum_width = -1;
- if (natural_width)
- *natural_width = 848;
+ if (natural_width)
+ *natural_width = 848;
}
static void
ephy_location_entry_copy_clipboard (GtkEntry *entry)
{
- char *text;
- gint start;
- gint end;
-
- if (!gtk_editable_get_selection_bounds (GTK_EDITABLE (entry), &start, &end))
- return;
-
- text = gtk_editable_get_chars (GTK_EDITABLE (entry), start, end);
-
- if (start == 0)
- {
- char *tmp = text;
- text = ephy_uri_normalize (tmp);
- g_free (tmp);
- }
-
- gtk_clipboard_set_text (gtk_widget_get_clipboard (GTK_WIDGET (entry),
- GDK_SELECTION_CLIPBOARD),
- text, -1);
- g_free (text);
+ char *text;
+ gint start;
+ gint end;
+
+ if (!gtk_editable_get_selection_bounds (GTK_EDITABLE (entry), &start, &end))
+ return;
+
+ text = gtk_editable_get_chars (GTK_EDITABLE (entry), start, end);
+
+ if (start == 0) {
+ char *tmp = text;
+ text = ephy_uri_normalize (tmp);
+ g_free (tmp);
+ }
+
+ gtk_clipboard_set_text (gtk_widget_get_clipboard (GTK_WIDGET (entry),
+ GDK_SELECTION_CLIPBOARD),
+ text, -1);
+ g_free (text);
}
static void
ephy_location_entry_cut_clipboard (GtkEntry *entry)
{
- if (!gtk_editable_get_editable (GTK_EDITABLE (entry)))
- {
- gtk_widget_error_bell (GTK_WIDGET (entry));
- return;
- }
-
- ephy_location_entry_copy_clipboard (entry);
- gtk_editable_delete_selection (GTK_EDITABLE (entry));
+ if (!gtk_editable_get_editable (GTK_EDITABLE (entry))) {
+ gtk_widget_error_bell (GTK_WIDGET (entry));
+ return;
+ }
+
+ ephy_location_entry_copy_clipboard (entry);
+ gtk_editable_delete_selection (GTK_EDITABLE (entry));
}
static void
ephy_location_entry_class_init (EphyLocationEntryClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
- GtkEntryClass *entry_class = GTK_ENTRY_CLASS (klass);
-
- object_class->get_property = ephy_location_entry_get_property;
- object_class->set_property = ephy_location_entry_set_property;
- object_class->finalize = ephy_location_entry_finalize;
- widget_class->get_preferred_width = ephy_location_entry_get_preferred_width;
- entry_class->copy_clipboard = ephy_location_entry_copy_clipboard;
- entry_class->cut_clipboard = ephy_location_entry_cut_clipboard;
-
- /**
- * EphyLocationEntry:location:
- *
- * The current location.
- */
- obj_properties[PROP_LOCATION] =
- g_param_spec_string ("location",
- "Location",
- "The current location",
- "",
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
-
- /**
- * EphyLocationEntry:favicon:
- *
- * The icon corresponding to the current location.
- */
- obj_properties[PROP_FAVICON] =
- g_param_spec_object ("favicon",
- "Favicon",
- "The icon corresponding to the current location",
- GDK_TYPE_PIXBUF,
- G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS);
-
- /**
- * EphyLocationEntry:security-level:
- *
- * State of the security icon.
- */
- obj_properties[PROP_SECURITY_LEVEL] =
- g_param_spec_enum ("security-level",
- "Security level",
- "State of the security icon",
- EPHY_TYPE_SECURITY_LEVEL,
- EPHY_SECURITY_LEVEL_TO_BE_DETERMINED,
- G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS);
-
- obj_properties[PROP_SHOW_FAVICON] =
- g_param_spec_boolean ("show-favicon",
- "Show Favicon",
- "Whether to show the favicon",
- TRUE,
- G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS);
-
- g_object_class_install_properties (object_class, LAST_PROP, obj_properties);
-
- /**
- * EphyLocationEntry::user-changed:
- * @entry: the object on which the signal is emitted
- *
- * Emitted when the user changes the contents of the internal #GtkEntry
- *
- */
- signals[USER_CHANGED] = g_signal_new (
- "user_changed", G_OBJECT_CLASS_TYPE (klass),
- G_SIGNAL_RUN_FIRST | G_SIGNAL_RUN_LAST,
- 0, NULL, NULL, NULL,
- G_TYPE_NONE,
- 0,
- G_TYPE_NONE);
-
- /**
- * EphyLocationEntry::lock-clicked:
- * @entry: the object on which the signal is emitted
- *
- * Emitted when the user clicks the security icon inside the
- * #EphyLocationEntry.
- *
- */
- signals[LOCK_CLICKED] = g_signal_new (
- "lock-clicked",
- EPHY_TYPE_LOCATION_ENTRY,
- G_SIGNAL_RUN_FIRST | G_SIGNAL_RUN_LAST,
- 0, NULL, NULL, NULL,
- G_TYPE_NONE,
- 0);
-
- /**
- * EphyLocationEntry::get-location:
- * @entry: the object on which the signal is emitted
- * Returns: the current page address as a string
- *
- * For drag and drop purposes, the location bar will request you the
- * real address of where it is pointing to. The signal handler for this
- * function should return the address of the currently loaded site.
- *
- */
- signals[GET_LOCATION] = g_signal_new (
- "get-location", G_OBJECT_CLASS_TYPE (klass),
- G_SIGNAL_RUN_FIRST | G_SIGNAL_RUN_LAST,
- 0, ephy_signal_accumulator_string,
- NULL, NULL,
- G_TYPE_STRING,
- 0,
- G_TYPE_NONE);
-
- /**
- * EphyLocationEntry::get-title:
- * @entry: the object on which the signal is emitted
- * Returns: the current page title as a string
- *
- * For drag and drop purposes, the location bar will request you the
- * title of where it is pointing to. The signal handler for this
- * function should return the title of the currently loaded site.
- *
- */
- signals[GET_TITLE] = g_signal_new (
- "get-title", G_OBJECT_CLASS_TYPE (klass),
- G_SIGNAL_RUN_FIRST | G_SIGNAL_RUN_LAST,
- 0, ephy_signal_accumulator_string,
- NULL, NULL,
- G_TYPE_STRING,
- 0,
- G_TYPE_NONE);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+ GtkEntryClass *entry_class = GTK_ENTRY_CLASS (klass);
+
+ object_class->get_property = ephy_location_entry_get_property;
+ object_class->set_property = ephy_location_entry_set_property;
+ object_class->finalize = ephy_location_entry_finalize;
+ widget_class->get_preferred_width = ephy_location_entry_get_preferred_width;
+ entry_class->copy_clipboard = ephy_location_entry_copy_clipboard;
+ entry_class->cut_clipboard = ephy_location_entry_cut_clipboard;
+
+ /**
+ * EphyLocationEntry:location:
+ *
+ * The current location.
+ */
+ obj_properties[PROP_LOCATION] =
+ g_param_spec_string ("location",
+ "Location",
+ "The current location",
+ "",
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+
+ /**
+ * EphyLocationEntry:favicon:
+ *
+ * The icon corresponding to the current location.
+ */
+ obj_properties[PROP_FAVICON] =
+ g_param_spec_object ("favicon",
+ "Favicon",
+ "The icon corresponding to the current location",
+ GDK_TYPE_PIXBUF,
+ G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS);
+
+ /**
+ * EphyLocationEntry:security-level:
+ *
+ * State of the security icon.
+ */
+ obj_properties[PROP_SECURITY_LEVEL] =
+ g_param_spec_enum ("security-level",
+ "Security level",
+ "State of the security icon",
+ EPHY_TYPE_SECURITY_LEVEL,
+ EPHY_SECURITY_LEVEL_TO_BE_DETERMINED,
+ G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS);
+
+ obj_properties[PROP_SHOW_FAVICON] =
+ g_param_spec_boolean ("show-favicon",
+ "Show Favicon",
+ "Whether to show the favicon",
+ TRUE,
+ G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS);
+
+ g_object_class_install_properties (object_class, LAST_PROP, obj_properties);
+
+ /**
+ * EphyLocationEntry::user-changed:
+ * @entry: the object on which the signal is emitted
+ *
+ * Emitted when the user changes the contents of the internal #GtkEntry
+ *
+ */
+ signals[USER_CHANGED] = g_signal_new (
+ "user_changed", G_OBJECT_CLASS_TYPE (klass),
+ G_SIGNAL_RUN_FIRST | G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL, NULL,
+ G_TYPE_NONE,
+ 0,
+ G_TYPE_NONE);
+
+ /**
+ * EphyLocationEntry::lock-clicked:
+ * @entry: the object on which the signal is emitted
+ *
+ * Emitted when the user clicks the security icon inside the
+ * #EphyLocationEntry.
+ *
+ */
+ signals[LOCK_CLICKED] = g_signal_new (
+ "lock-clicked",
+ EPHY_TYPE_LOCATION_ENTRY,
+ G_SIGNAL_RUN_FIRST | G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL, NULL,
+ G_TYPE_NONE,
+ 0);
+
+ /**
+ * EphyLocationEntry::get-location:
+ * @entry: the object on which the signal is emitted
+ * Returns: the current page address as a string
+ *
+ * For drag and drop purposes, the location bar will request you the
+ * real address of where it is pointing to. The signal handler for this
+ * function should return the address of the currently loaded site.
+ *
+ */
+ signals[GET_LOCATION] = g_signal_new (
+ "get-location", G_OBJECT_CLASS_TYPE (klass),
+ G_SIGNAL_RUN_FIRST | G_SIGNAL_RUN_LAST,
+ 0, ephy_signal_accumulator_string,
+ NULL, NULL,
+ G_TYPE_STRING,
+ 0,
+ G_TYPE_NONE);
+
+ /**
+ * EphyLocationEntry::get-title:
+ * @entry: the object on which the signal is emitted
+ * Returns: the current page title as a string
+ *
+ * For drag and drop purposes, the location bar will request you the
+ * title of where it is pointing to. The signal handler for this
+ * function should return the title of the currently loaded site.
+ *
+ */
+ signals[GET_TITLE] = g_signal_new (
+ "get-title", G_OBJECT_CLASS_TYPE (klass),
+ G_SIGNAL_RUN_FIRST | G_SIGNAL_RUN_LAST,
+ 0, ephy_signal_accumulator_string,
+ NULL, NULL,
+ G_TYPE_STRING,
+ 0,
+ G_TYPE_NONE);
}
static void
update_address_state (EphyLocationEntry *entry)
{
- const char *text;
+ const char *text;
- text = gtk_entry_get_text (GTK_ENTRY (entry));
- entry->original_address = text != NULL &&
- g_str_hash (text) == entry->hash;
+ text = gtk_entry_get_text (GTK_ENTRY (entry));
+ entry->original_address = text != NULL &&
+ g_str_hash (text) == entry->hash;
}
static void
update_favicon (EphyLocationEntry *lentry)
{
- GtkEntry *entry = GTK_ENTRY (lentry);
-
- /* Only show the favicon if the entry's text is the
- * address of the current page.
- */
- if (lentry->show_favicon && lentry->favicon != NULL && lentry->original_address)
- {
- gtk_entry_set_icon_from_pixbuf (entry,
- GTK_ENTRY_ICON_PRIMARY,
- lentry->favicon);
- }
- else if (lentry->show_favicon)
- {
- const char *icon_name;
-
- /* Here we could consider using fallback favicon that matches
- * the page MIME type, though text/html should be good enough
- * most of the time. See #337140
- */
- if (gtk_entry_get_text_length (entry) > 0)
- icon_name = "text-x-generic-symbolic";
- else
- icon_name = "edit-find-symbolic";
-
- gtk_entry_set_icon_from_icon_name (entry,
- GTK_ENTRY_ICON_PRIMARY,
- icon_name);
- }
- else
- {
- gtk_entry_set_icon_from_icon_name (entry,
- GTK_ENTRY_ICON_PRIMARY,
- NULL);
- }
+ GtkEntry *entry = GTK_ENTRY (lentry);
+
+ /* Only show the favicon if the entry's text is the
+ * address of the current page.
+ */
+ if (lentry->show_favicon && lentry->favicon != NULL && lentry->original_address) {
+ gtk_entry_set_icon_from_pixbuf (entry,
+ GTK_ENTRY_ICON_PRIMARY,
+ lentry->favicon);
+ } else if (lentry->show_favicon) {
+ const char *icon_name;
+
+ /* Here we could consider using fallback favicon that matches
+ * the page MIME type, though text/html should be good enough
+ * most of the time. See #337140
+ */
+ if (gtk_entry_get_text_length (entry) > 0)
+ icon_name = "text-x-generic-symbolic";
+ else
+ icon_name = "edit-find-symbolic";
+
+ gtk_entry_set_icon_from_icon_name (entry,
+ GTK_ENTRY_ICON_PRIMARY,
+ icon_name);
+ } else {
+ gtk_entry_set_icon_from_icon_name (entry,
+ GTK_ENTRY_ICON_PRIMARY,
+ NULL);
+ }
}
static void
-editable_changed_cb (GtkEditable *editable,
- EphyLocationEntry *entry)
+editable_changed_cb (GtkEditable *editable,
+ EphyLocationEntry *entry)
{
- update_address_state (entry);
+ update_address_state (entry);
- if (entry->block_update == TRUE)
- return;
- else
- {
- entry->user_changed = TRUE;
- entry->can_redo = FALSE;
- }
+ if (entry->block_update == TRUE)
+ return;
+ else {
+ entry->user_changed = TRUE;
+ entry->can_redo = FALSE;
+ }
- g_signal_emit (entry, signals[USER_CHANGED], 0);
+ g_signal_emit (entry, signals[USER_CHANGED], 0);
}
static gboolean
-entry_key_press_cb (GtkEntry *entry,
- GdkEventKey *event,
- EphyLocationEntry *location_entry)
+entry_key_press_cb (GtkEntry *entry,
+ GdkEventKey *event,
+ EphyLocationEntry *location_entry)
{
- guint state = event->state & gtk_accelerator_get_default_mod_mask ();
+ guint state = event->state & gtk_accelerator_get_default_mod_mask ();
- if (event->keyval == GDK_KEY_Escape && state == 0)
- {
- ephy_location_entry_reset_internal (location_entry, TRUE);
- /* don't return TRUE since we want to cancel the autocompletion popup too */
- }
+ if (event->keyval == GDK_KEY_Escape && state == 0) {
+ ephy_location_entry_reset_internal (location_entry, TRUE);
+ /* don't return TRUE since we want to cancel the autocompletion popup too */
+ }
- if (event->keyval == GDK_KEY_l && state == GDK_CONTROL_MASK)
- {
- /* Make sure the location is activated on CTRL+l even when the
- * completion popup is shown and have an active keyboard grab.
- */
- ephy_location_entry_activate (location_entry);
- }
+ if (event->keyval == GDK_KEY_l && state == GDK_CONTROL_MASK) {
+ /* Make sure the location is activated on CTRL+l even when the
+ * completion popup is shown and have an active keyboard grab.
+ */
+ ephy_location_entry_activate (location_entry);
+ }
- return FALSE;
+ return FALSE;
}
static gboolean
-entry_key_press_after_cb (GtkEntry *entry,
- GdkEventKey *event,
- EphyLocationEntry *lentry)
+entry_key_press_after_cb (GtkEntry *entry,
+ GdkEventKey *event,
+ EphyLocationEntry *lentry)
{
- guint state = event->state & gtk_accelerator_get_default_mod_mask ();
-
- if ((event->keyval == GDK_KEY_Return ||
- event->keyval == GDK_KEY_KP_Enter ||
- event->keyval == GDK_KEY_ISO_Enter) &&
- (state == GDK_CONTROL_MASK ||
- state == (GDK_CONTROL_MASK | GDK_SHIFT_MASK)))
- {
- //gtk_im_context_reset (entry->im_context);
-
- lentry->needs_reset = TRUE;
- g_signal_emit_by_name (entry, "activate");
-
- return TRUE;
- }
-
- if ((event->keyval == GDK_KEY_Down || event->keyval == GDK_KEY_KP_Down)
- && state == 0)
- {
- /* If we are focusing the entry, with the cursor at the end of it
- * we emit the changed signal, so that the completion popup appears */
- const char *string;
-
- string = gtk_entry_get_text (entry);
- if (gtk_editable_get_position (GTK_EDITABLE (entry)) == (int)strlen (string))
- {
- g_signal_emit_by_name (entry, "changed", 0);
- return TRUE;
- }
- }
-
- return FALSE;
+ guint state = event->state & gtk_accelerator_get_default_mod_mask ();
+
+ if ((event->keyval == GDK_KEY_Return ||
+ event->keyval == GDK_KEY_KP_Enter ||
+ event->keyval == GDK_KEY_ISO_Enter) &&
+ (state == GDK_CONTROL_MASK ||
+ state == (GDK_CONTROL_MASK | GDK_SHIFT_MASK))) {
+ /* gtk_im_context_reset (entry->im_context); */
+
+ lentry->needs_reset = TRUE;
+ g_signal_emit_by_name (entry, "activate");
+
+ return TRUE;
+ }
+
+ if ((event->keyval == GDK_KEY_Down || event->keyval == GDK_KEY_KP_Down)
+ && state == 0) {
+ /* If we are focusing the entry, with the cursor at the end of it
+ * we emit the changed signal, so that the completion popup appears */
+ const char *string;
+
+ string = gtk_entry_get_text (entry);
+ if (gtk_editable_get_position (GTK_EDITABLE (entry)) == (int)strlen (string)) {
+ g_signal_emit_by_name (entry, "changed", 0);
+ return TRUE;
+ }
+ }
+
+ return FALSE;
}
static void
-entry_activate_after_cb (GtkEntry *entry,
- EphyLocationEntry *lentry)
+entry_activate_after_cb (GtkEntry *entry,
+ EphyLocationEntry *lentry)
{
- lentry->user_changed = FALSE;
+ lentry->user_changed = FALSE;
- if (lentry->needs_reset)
- {
- ephy_location_entry_reset_internal (lentry, TRUE);
- lentry->needs_reset = FALSE;
- }
+ if (lentry->needs_reset) {
+ ephy_location_entry_reset_internal (lentry, TRUE);
+ lentry->needs_reset = FALSE;
+ }
}
static gboolean
match_selected_cb (GtkEntryCompletion *completion,
- GtkTreeModel *model,
- GtkTreeIter *iter,
- EphyLocationEntry *entry)
+ GtkTreeModel *model,
+ GtkTreeIter *iter,
+ EphyLocationEntry *entry)
{
- char *item = NULL;
- guint state;
+ char *item = NULL;
+ guint state;
- gtk_tree_model_get (model, iter,
- entry->action_col, &item, -1);
- if (item == NULL) return FALSE;
+ gtk_tree_model_get (model, iter,
+ entry->action_col, &item, -1);
+ if (item == NULL) return FALSE;
- ephy_gui_get_current_event (NULL, &state, NULL);
+ ephy_gui_get_current_event (NULL, &state, NULL);
- entry->needs_reset = (state == GDK_CONTROL_MASK ||
- state == (GDK_CONTROL_MASK | GDK_SHIFT_MASK));
+ entry->needs_reset = (state == GDK_CONTROL_MASK ||
+ state == (GDK_CONTROL_MASK | GDK_SHIFT_MASK));
- ephy_location_entry_set_location (entry, item);
- //gtk_im_context_reset (GTK_ENTRY (entry)->im_context);
- g_signal_emit_by_name (entry, "activate");
+ ephy_location_entry_set_location (entry, item);
+ /* gtk_im_context_reset (GTK_ENTRY (entry)->im_context); */
+ g_signal_emit_by_name (entry, "activate");
- g_free (item);
+ g_free (item);
- return TRUE;
+ return TRUE;
}
static void
action_activated_after_cb (GtkEntryCompletion *completion,
- gint index,
- EphyLocationEntry *lentry)
+ gint index,
+ EphyLocationEntry *lentry)
{
- guint state, button;
-
- ephy_gui_get_current_event (NULL, &state, &button);
- if ((state == GDK_CONTROL_MASK ||
- state == (GDK_CONTROL_MASK | GDK_SHIFT_MASK)) ||
- button == 2)
- {
- ephy_location_entry_reset_internal (lentry, TRUE);
- }
+ guint state, button;
+
+ ephy_gui_get_current_event (NULL, &state, &button);
+ if ((state == GDK_CONTROL_MASK ||
+ state == (GDK_CONTROL_MASK | GDK_SHIFT_MASK)) ||
+ button == 2) {
+ ephy_location_entry_reset_internal (lentry, TRUE);
+ }
}
static gboolean
-entry_drag_motion_cb (GtkWidget *widget,
- GdkDragContext *context,
- gint x,
- gint y,
- guint time)
+entry_drag_motion_cb (GtkWidget *widget,
+ GdkDragContext *context,
+ gint x,
+ gint y,
+ guint time)
{
- return FALSE;
+ return FALSE;
}
static gboolean
-entry_drag_drop_cb (GtkWidget *widget,
- GdkDragContext *context,
- gint x,
- gint y,
- guint time)
+entry_drag_drop_cb (GtkWidget *widget,
+ GdkDragContext *context,
+ gint x,
+ gint y,
+ guint time)
{
- return FALSE;
+ return FALSE;
}
static void
-entry_clear_activate_cb (GtkMenuItem *item,
- EphyLocationEntry *entry)
+entry_clear_activate_cb (GtkMenuItem *item,
+ EphyLocationEntry *entry)
{
- entry->block_update = TRUE;
- gtk_entry_set_text (GTK_ENTRY (entry), "");
- entry->block_update = FALSE;
- entry->user_changed = TRUE;
+ entry->block_update = TRUE;
+ gtk_entry_set_text (GTK_ENTRY (entry), "");
+ entry->block_update = FALSE;
+ entry->user_changed = TRUE;
}
static void
-entry_redo_activate_cb (GtkMenuItem *item,
- EphyLocationEntry *entry)
+entry_redo_activate_cb (GtkMenuItem *item,
+ EphyLocationEntry *entry)
{
- ephy_location_entry_undo_reset (entry);
+ ephy_location_entry_undo_reset (entry);
}
static void
-entry_undo_activate_cb (GtkMenuItem *item,
- EphyLocationEntry *entry)
+entry_undo_activate_cb (GtkMenuItem *item,
+ EphyLocationEntry *entry)
{
- ephy_location_entry_reset_internal (entry, FALSE);
+ ephy_location_entry_reset_internal (entry, FALSE);
}
static void
-entry_populate_popup_cb (GtkEntry *entry,
- GtkMenu *menu,
- EphyLocationEntry *lentry)
+entry_populate_popup_cb (GtkEntry *entry,
+ GtkMenu *menu,
+ EphyLocationEntry *lentry)
{
- GtkWidget *clear_menuitem, *undo_menuitem, *redo_menuitem, *separator;
- GList *children, *item;
- int pos = 0, sep = 0;
- gboolean is_editable;
-
- /* Translators: the mnemonic shouldn't conflict with any of the
- * standard items in the GtkEntry context menu (Cut, Copy, Paste, Delete,
- * Select All, Input Methods and Insert Unicode control character.)
- */
- clear_menuitem = gtk_menu_item_new_with_mnemonic (_("Cl_ear"));
- g_signal_connect (clear_menuitem , "activate",
- G_CALLBACK (entry_clear_activate_cb), lentry);
- is_editable = gtk_editable_get_editable (GTK_EDITABLE (entry));
- gtk_widget_set_sensitive (clear_menuitem, is_editable);
- gtk_widget_show (clear_menuitem);
-
- /* search for the 2nd separator (the one after Select All) in the context
- * menu, and insert this menu item before it.
- * It's a bit of a hack, but there seems to be no better way to do it :/
- */
- children = gtk_container_get_children (GTK_CONTAINER (menu));
- for (item = children; item != NULL && sep < 2; item = item->next, pos++)
- {
- if (GTK_IS_SEPARATOR_MENU_ITEM (item->data)) sep++;
- }
-
- gtk_menu_shell_insert (GTK_MENU_SHELL (menu), clear_menuitem, pos - 1);
-
- undo_menuitem = gtk_menu_item_new_with_mnemonic (_("_Undo"));
- gtk_widget_set_sensitive (undo_menuitem, lentry->user_changed);
- g_signal_connect (undo_menuitem, "activate",
- G_CALLBACK (entry_undo_activate_cb), lentry);
- gtk_widget_show (undo_menuitem);
- gtk_menu_shell_insert (GTK_MENU_SHELL (menu), undo_menuitem, 0);
-
- redo_menuitem = gtk_menu_item_new_with_mnemonic (_("_Redo"));
- gtk_widget_set_sensitive (redo_menuitem, lentry->can_redo);
- g_signal_connect (redo_menuitem, "activate",
- G_CALLBACK (entry_redo_activate_cb), lentry);
- gtk_widget_show (redo_menuitem);
- gtk_menu_shell_insert (GTK_MENU_SHELL (menu), redo_menuitem, 1);
-
- separator = gtk_separator_menu_item_new ();
- gtk_widget_show (separator);
- gtk_menu_shell_insert (GTK_MENU_SHELL (menu), separator, 2);
+ GtkWidget *clear_menuitem, *undo_menuitem, *redo_menuitem, *separator;
+ GList *children, *item;
+ int pos = 0, sep = 0;
+ gboolean is_editable;
+
+ /* Translators: the mnemonic shouldn't conflict with any of the
+ * standard items in the GtkEntry context menu (Cut, Copy, Paste, Delete,
+ * Select All, Input Methods and Insert Unicode control character.)
+ */
+ clear_menuitem = gtk_menu_item_new_with_mnemonic (_("Cl_ear"));
+ g_signal_connect (clear_menuitem, "activate",
+ G_CALLBACK (entry_clear_activate_cb), lentry);
+ is_editable = gtk_editable_get_editable (GTK_EDITABLE (entry));
+ gtk_widget_set_sensitive (clear_menuitem, is_editable);
+ gtk_widget_show (clear_menuitem);
+
+ /* search for the 2nd separator (the one after Select All) in the context
+ * menu, and insert this menu item before it.
+ * It's a bit of a hack, but there seems to be no better way to do it :/
+ */
+ children = gtk_container_get_children (GTK_CONTAINER (menu));
+ for (item = children; item != NULL && sep < 2; item = item->next, pos++) {
+ if (GTK_IS_SEPARATOR_MENU_ITEM (item->data)) sep++;
+ }
+
+ gtk_menu_shell_insert (GTK_MENU_SHELL (menu), clear_menuitem, pos - 1);
+
+ undo_menuitem = gtk_menu_item_new_with_mnemonic (_("_Undo"));
+ gtk_widget_set_sensitive (undo_menuitem, lentry->user_changed);
+ g_signal_connect (undo_menuitem, "activate",
+ G_CALLBACK (entry_undo_activate_cb), lentry);
+ gtk_widget_show (undo_menuitem);
+ gtk_menu_shell_insert (GTK_MENU_SHELL (menu), undo_menuitem, 0);
+
+ redo_menuitem = gtk_menu_item_new_with_mnemonic (_("_Redo"));
+ gtk_widget_set_sensitive (redo_menuitem, lentry->can_redo);
+ g_signal_connect (redo_menuitem, "activate",
+ G_CALLBACK (entry_redo_activate_cb), lentry);
+ gtk_widget_show (redo_menuitem);
+ gtk_menu_shell_insert (GTK_MENU_SHELL (menu), redo_menuitem, 1);
+
+ separator = gtk_separator_menu_item_new ();
+ gtk_widget_show (separator);
+ gtk_menu_shell_insert (GTK_MENU_SHELL (menu), separator, 2);
}
static void
each_url_get_data_binder (EphyDragEachSelectedItemDataGet iteratee,
- gpointer iterator_context,
- gpointer return_data)
+ gpointer iterator_context,
+ gpointer return_data)
{
- EphyLocationEntry *entry = EPHY_LOCATION_ENTRY (iterator_context);
- char *title = NULL, *address = NULL;
+ EphyLocationEntry *entry = EPHY_LOCATION_ENTRY (iterator_context);
+ char *title = NULL, *address = NULL;
- g_signal_emit (entry, signals[GET_LOCATION], 0, &address);
- g_signal_emit (entry, signals[GET_TITLE], 0, &title);
- g_return_if_fail (address != NULL && title != NULL);
+ g_signal_emit (entry, signals[GET_LOCATION], 0, &address);
+ g_signal_emit (entry, signals[GET_TITLE], 0, &title);
+ g_return_if_fail (address != NULL && title != NULL);
- iteratee (address, title, return_data);
+ iteratee (address, title, return_data);
- g_free (address);
- g_free (title);
+ g_free (address);
+ g_free (title);
}
static void
sanitize_location (char **url)
{
- char *str;
-
- /* Do not show internal ephy-about: protocol to users */
- if (g_str_has_prefix (*url, EPHY_ABOUT_SCHEME)) {
- str = g_strdup_printf ("about:%s", *url + strlen (EPHY_ABOUT_SCHEME) + 1);
- g_free (*url);
- *url = str;
- }
+ char *str;
+
+ /* Do not show internal ephy-about: protocol to users */
+ if (g_str_has_prefix (*url, EPHY_ABOUT_SCHEME)) {
+ str = g_strdup_printf ("about:%s", *url + strlen (EPHY_ABOUT_SCHEME) + 1);
+ g_free (*url);
+ *url = str;
+ }
}
-#define DRAG_ICON_LAYOUT_PADDING 5
-#define DRAG_ICON_ICON_PADDING 10
-#define DRAG_ICON_MAX_WIDTH_CHARS 32
+#define DRAG_ICON_LAYOUT_PADDING 5
+#define DRAG_ICON_ICON_PADDING 10
+#define DRAG_ICON_MAX_WIDTH_CHARS 32
static cairo_surface_t *
favicon_create_drag_surface (EphyLocationEntry *entry,
- GtkWidget *widget)
+ GtkWidget *widget)
{
- char *title = NULL, *address = NULL;
- GString *text;
- GtkStyleContext *style;
- const PangoFontDescription *font_desc;
- cairo_surface_t *surface;
- PangoContext *context;
- PangoLayout *layout;
- PangoFontMetrics *metrics;
- int surface_height, surface_width;
- int layout_width, layout_height;
- int icon_width = 0, icon_height = 0, favicon_offset_x = 0;
- int char_width;
- cairo_t *cr;
- GtkStateFlags state;
- GdkRGBA color;
- GdkPixbuf *favicon;
-
- g_signal_emit (entry, signals[GET_LOCATION], 0, &address);
- sanitize_location (&address);
- g_signal_emit (entry, signals[GET_TITLE], 0, &title);
- if (address == NULL || title == NULL) return NULL;
-
- /* Compute text */
- title = g_strstrip (title);
-
- text = g_string_sized_new (strlen (address) + strlen (title) + 2);
- if (title[0] != '\0')
- {
- g_string_append (text, title);
- g_string_append (text, "\n");
- }
-
- if (address[0] != '\0')
- {
- g_string_append (text, address);
- }
-
- if (entry->favicon != NULL)
- favicon = g_object_ref (entry->favicon);
- else
- favicon = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
- "text-x-generic-symbolic",
- 16,
- 0, NULL);
- if (favicon != NULL)
- {
- icon_width = gdk_pixbuf_get_width (favicon);
- icon_height = gdk_pixbuf_get_height (favicon);
- }
-
- context = gtk_widget_get_pango_context (widget);
- layout = pango_layout_new (context);
-
- style = gtk_widget_get_style_context (GTK_WIDGET (entry));
- state = gtk_style_context_get_state (style);
-
- gtk_style_context_save (style);
- gtk_style_context_set_state (style, GTK_STATE_FLAG_NORMAL);
- gtk_style_context_get (style, GTK_STATE_FLAG_NORMAL,
- "font", &font_desc, NULL);
- gtk_style_context_restore (style);
-
- metrics = pango_context_get_metrics (context,
- font_desc,
- pango_context_get_language (context));
-
- char_width = pango_font_metrics_get_approximate_digit_width (metrics);
- pango_font_metrics_unref (metrics);
-
- pango_layout_set_ellipsize (layout, PANGO_ELLIPSIZE_END);
- pango_layout_set_width (layout, char_width * DRAG_ICON_MAX_WIDTH_CHARS);
- pango_layout_set_text (layout, text->str, text->len);
-
- pango_layout_get_pixel_size (layout, &layout_width, &layout_height);
-
- if (favicon != NULL)
- {
- favicon_offset_x = icon_width + (2 * DRAG_ICON_ICON_PADDING);
- }
-
- surface_width = layout_width + favicon_offset_x +
- (DRAG_ICON_LAYOUT_PADDING * 3);
- surface_height = MAX (layout_height, icon_height) +
- (DRAG_ICON_LAYOUT_PADDING * 2);
-
- surface = gdk_window_create_similar_surface (gtk_widget_get_window (widget),
- CAIRO_CONTENT_COLOR,
- surface_width + 2,
- surface_height + 2);
- cr = cairo_create (surface);
-
- cairo_rectangle (cr, 1, 1, surface_width, surface_height);
- cairo_set_line_width (cr, 1.0);
-
- cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
- cairo_stroke_preserve (cr);
-
- gtk_style_context_get_background_color (style, state, &color);
- gdk_cairo_set_source_rgba (cr, &color);
- cairo_fill (cr);
-
- if (favicon != NULL)
- {
- double x;
- double y;
-
- x = 1 + DRAG_ICON_LAYOUT_PADDING + DRAG_ICON_ICON_PADDING;
- y = (surface_height - icon_height) / 2;
- gdk_cairo_set_source_pixbuf (cr, favicon, x, y);
- cairo_rectangle (cr, x, y, icon_width, icon_height);
- cairo_fill (cr);
- }
-
- cairo_move_to (cr,
- 1 + DRAG_ICON_LAYOUT_PADDING + favicon_offset_x,
- 1 + DRAG_ICON_LAYOUT_PADDING);
- gtk_style_context_get_color (style, state, &color);
- gdk_cairo_set_source_rgba (cr, &color);
- pango_cairo_show_layout (cr, layout);
-
- cairo_destroy (cr);
- g_object_unref (layout);
-
- g_free (address);
- g_free (title);
- g_string_free (text, TRUE);
- g_clear_object (&favicon);
-
- return surface;
+ char *title = NULL, *address = NULL;
+ GString *text;
+ GtkStyleContext *style;
+ const PangoFontDescription *font_desc;
+ cairo_surface_t *surface;
+ PangoContext *context;
+ PangoLayout *layout;
+ PangoFontMetrics *metrics;
+ int surface_height, surface_width;
+ int layout_width, layout_height;
+ int icon_width = 0, icon_height = 0, favicon_offset_x = 0;
+ int char_width;
+ cairo_t *cr;
+ GtkStateFlags state;
+ GdkRGBA color;
+ GdkPixbuf *favicon;
+
+ g_signal_emit (entry, signals[GET_LOCATION], 0, &address);
+ sanitize_location (&address);
+ g_signal_emit (entry, signals[GET_TITLE], 0, &title);
+ if (address == NULL || title == NULL) return NULL;
+
+ /* Compute text */
+ title = g_strstrip (title);
+
+ text = g_string_sized_new (strlen (address) + strlen (title) + 2);
+ if (title[0] != '\0') {
+ g_string_append (text, title);
+ g_string_append (text, "\n");
+ }
+
+ if (address[0] != '\0') {
+ g_string_append (text, address);
+ }
+
+ if (entry->favicon != NULL)
+ favicon = g_object_ref (entry->favicon);
+ else
+ favicon = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
+ "text-x-generic-symbolic",
+ 16,
+ 0, NULL);
+ if (favicon != NULL) {
+ icon_width = gdk_pixbuf_get_width (favicon);
+ icon_height = gdk_pixbuf_get_height (favicon);
+ }
+
+ context = gtk_widget_get_pango_context (widget);
+ layout = pango_layout_new (context);
+
+ style = gtk_widget_get_style_context (GTK_WIDGET (entry));
+ state = gtk_style_context_get_state (style);
+
+ gtk_style_context_save (style);
+ gtk_style_context_set_state (style, GTK_STATE_FLAG_NORMAL);
+ gtk_style_context_get (style, GTK_STATE_FLAG_NORMAL,
+ "font", &font_desc, NULL);
+ gtk_style_context_restore (style);
+
+ metrics = pango_context_get_metrics (context,
+ font_desc,
+ pango_context_get_language (context));
+
+ char_width = pango_font_metrics_get_approximate_digit_width (metrics);
+ pango_font_metrics_unref (metrics);
+
+ pango_layout_set_ellipsize (layout, PANGO_ELLIPSIZE_END);
+ pango_layout_set_width (layout, char_width * DRAG_ICON_MAX_WIDTH_CHARS);
+ pango_layout_set_text (layout, text->str, text->len);
+
+ pango_layout_get_pixel_size (layout, &layout_width, &layout_height);
+
+ if (favicon != NULL) {
+ favicon_offset_x = icon_width + (2 * DRAG_ICON_ICON_PADDING);
+ }
+
+ surface_width = layout_width + favicon_offset_x +
+ (DRAG_ICON_LAYOUT_PADDING * 3);
+ surface_height = MAX (layout_height, icon_height) +
+ (DRAG_ICON_LAYOUT_PADDING * 2);
+
+ surface = gdk_window_create_similar_surface (gtk_widget_get_window (widget),
+ CAIRO_CONTENT_COLOR,
+ surface_width + 2,
+ surface_height + 2);
+ cr = cairo_create (surface);
+
+ cairo_rectangle (cr, 1, 1, surface_width, surface_height);
+ cairo_set_line_width (cr, 1.0);
+
+ cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
+ cairo_stroke_preserve (cr);
+
+ gtk_style_context_get_background_color (style, state, &color);
+ gdk_cairo_set_source_rgba (cr, &color);
+ cairo_fill (cr);
+
+ if (favicon != NULL) {
+ double x;
+ double y;
+
+ x = 1 + DRAG_ICON_LAYOUT_PADDING + DRAG_ICON_ICON_PADDING;
+ y = (surface_height - icon_height) / 2;
+ gdk_cairo_set_source_pixbuf (cr, favicon, x, y);
+ cairo_rectangle (cr, x, y, icon_width, icon_height);
+ cairo_fill (cr);
+ }
+
+ cairo_move_to (cr,
+ 1 + DRAG_ICON_LAYOUT_PADDING + favicon_offset_x,
+ 1 + DRAG_ICON_LAYOUT_PADDING);
+ gtk_style_context_get_color (style, state, &color);
+ gdk_cairo_set_source_rgba (cr, &color);
+ pango_cairo_show_layout (cr, layout);
+
+ cairo_destroy (cr);
+ g_object_unref (layout);
+
+ g_free (address);
+ g_free (title);
+ g_string_free (text, TRUE);
+ g_clear_object (&favicon);
+
+ return surface;
}
static void
-favicon_drag_begin_cb (GtkWidget *widget,
- GdkDragContext *context,
- EphyLocationEntry *lentry)
+favicon_drag_begin_cb (GtkWidget *widget,
+ GdkDragContext *context,
+ EphyLocationEntry *lentry)
{
- cairo_surface_t *surface;
- GtkEntry *entry;
- gint index;
+ cairo_surface_t *surface;
+ GtkEntry *entry;
+ gint index;
- entry = GTK_ENTRY (widget);
+ entry = GTK_ENTRY (widget);
- index = gtk_entry_get_current_icon_drag_source (entry);
- if (index != GTK_ENTRY_ICON_PRIMARY)
- return;
+ index = gtk_entry_get_current_icon_drag_source (entry);
+ if (index != GTK_ENTRY_ICON_PRIMARY)
+ return;
- surface = favicon_create_drag_surface (lentry, widget);
+ surface = favicon_create_drag_surface (lentry, widget);
- if (surface != NULL)
- {
- gtk_drag_set_icon_surface (context, surface);
- cairo_surface_destroy (surface);
- }
+ if (surface != NULL) {
+ gtk_drag_set_icon_surface (context, surface);
+ cairo_surface_destroy (surface);
+ }
}
static void
-favicon_drag_data_get_cb (GtkWidget *widget,
- GdkDragContext *context,
- GtkSelectionData *selection_data,
- guint info,
- guint32 time,
- EphyLocationEntry *lentry)
+favicon_drag_data_get_cb (GtkWidget *widget,
+ GdkDragContext *context,
+ GtkSelectionData *selection_data,
+ guint info,
+ guint32 time,
+ EphyLocationEntry *lentry)
{
- gint index;
- GtkEntry *entry;
+ gint index;
+ GtkEntry *entry;
- g_assert (widget != NULL);
- g_return_if_fail (context != NULL);
+ g_assert (widget != NULL);
+ g_return_if_fail (context != NULL);
- entry = GTK_ENTRY (widget);
+ entry = GTK_ENTRY (widget);
- index = gtk_entry_get_current_icon_drag_source (entry);
- if (index == GTK_ENTRY_ICON_PRIMARY)
- {
- ephy_dnd_drag_data_get (widget, context, selection_data,
- time, lentry, each_url_get_data_binder);
- }
+ index = gtk_entry_get_current_icon_drag_source (entry);
+ if (index == GTK_ENTRY_ICON_PRIMARY) {
+ ephy_dnd_drag_data_get (widget, context, selection_data,
+ time, lentry, each_url_get_data_binder);
+ }
}
static gboolean
-icon_button_press_event_cb (GtkWidget *entry,
- GtkEntryIconPosition position,
- GdkEventButton *event,
- EphyLocationEntry *lentry)
+icon_button_press_event_cb (GtkWidget *entry,
+ GtkEntryIconPosition position,
+ GdkEventButton *event,
+ EphyLocationEntry *lentry)
{
- guint state = event->state & gtk_accelerator_get_default_mod_mask ();
-
- if (event->type == GDK_BUTTON_PRESS &&
- event->button == 1 &&
- state == 0 /* left */)
- {
- if (position == GTK_ENTRY_ICON_PRIMARY)
- {
- GtkWidget *toplevel;
-
- toplevel = gtk_widget_get_toplevel (GTK_WIDGET (entry));
- gtk_window_set_focus (GTK_WINDOW (toplevel), entry);
-
- gtk_editable_select_region (GTK_EDITABLE (entry), 0, -1);
- }
- else
- {
- g_signal_emit (lentry, signals[LOCK_CLICKED], 0);
- }
-
- return TRUE;
- }
-
- return FALSE;
+ guint state = event->state & gtk_accelerator_get_default_mod_mask ();
+
+ if (event->type == GDK_BUTTON_PRESS &&
+ event->button == 1 &&
+ state == 0 /* left */) {
+ if (position == GTK_ENTRY_ICON_PRIMARY) {
+ GtkWidget *toplevel;
+
+ toplevel = gtk_widget_get_toplevel (GTK_WIDGET (entry));
+ gtk_window_set_focus (GTK_WINDOW (toplevel), entry);
+
+ gtk_editable_select_region (GTK_EDITABLE (entry), 0, -1);
+ } else {
+ g_signal_emit (lentry, signals[LOCK_CLICKED], 0);
+ }
+
+ return TRUE;
+ }
+
+ return FALSE;
}
static void
ephy_location_entry_construct_contents (EphyLocationEntry *lentry)
{
- GtkWidget *entry = GTK_WIDGET (lentry);
-
- LOG ("EphyLocationEntry constructing contents %p", lentry);
-
- /* Favicon */
- lentry->drag_targets = gtk_target_list_new (url_drag_types,
- G_N_ELEMENTS (url_drag_types));
- lentry->drag_actions = GDK_ACTION_ASK | GDK_ACTION_COPY | GDK_ACTION_LINK;
-
- gtk_entry_set_icon_drag_source (GTK_ENTRY (entry),
- GTK_ENTRY_ICON_PRIMARY,
- lentry->drag_targets,
- lentry->drag_actions);
-
- gtk_entry_set_icon_tooltip_text (GTK_ENTRY (entry),
- GTK_ENTRY_ICON_PRIMARY,
- _("Drag and drop this icon to create a link to this page"));
-
- gtk_drag_dest_set (entry,
- GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_DROP,
- url_drag_types,
- G_N_ELEMENTS (url_drag_types),
- GDK_ACTION_MOVE | GDK_ACTION_COPY);
-
- g_object_connect (entry,
- "signal::icon-press", G_CALLBACK (icon_button_press_event_cb), lentry,
- "signal::populate-popup", G_CALLBACK (entry_populate_popup_cb), lentry,
- "signal::key-press-event", G_CALLBACK (entry_key_press_cb), lentry,
- "signal::changed", G_CALLBACK (editable_changed_cb), lentry,
- "signal::drag-motion", G_CALLBACK (entry_drag_motion_cb), lentry,
- "signal::drag-drop", G_CALLBACK (entry_drag_drop_cb), lentry,
- "signal::drag-data-get", G_CALLBACK (favicon_drag_data_get_cb), lentry,
- NULL);
-
- g_signal_connect_after (entry, "key-press-event",
- G_CALLBACK (entry_key_press_after_cb), lentry);
- g_signal_connect_after (entry, "activate",
- G_CALLBACK (entry_activate_after_cb), lentry);
- g_signal_connect_after (entry, "drag-begin",
- G_CALLBACK (favicon_drag_begin_cb), lentry);
+ GtkWidget *entry = GTK_WIDGET (lentry);
+
+ LOG ("EphyLocationEntry constructing contents %p", lentry);
+
+ /* Favicon */
+ lentry->drag_targets = gtk_target_list_new (url_drag_types,
+ G_N_ELEMENTS (url_drag_types));
+ lentry->drag_actions = GDK_ACTION_ASK | GDK_ACTION_COPY | GDK_ACTION_LINK;
+
+ gtk_entry_set_icon_drag_source (GTK_ENTRY (entry),
+ GTK_ENTRY_ICON_PRIMARY,
+ lentry->drag_targets,
+ lentry->drag_actions);
+
+ gtk_entry_set_icon_tooltip_text (GTK_ENTRY (entry),
+ GTK_ENTRY_ICON_PRIMARY,
+ _("Drag and drop this icon to create a link to this page"));
+
+ gtk_drag_dest_set (entry,
+ GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_DROP,
+ url_drag_types,
+ G_N_ELEMENTS (url_drag_types),
+ GDK_ACTION_MOVE | GDK_ACTION_COPY);
+
+ g_object_connect (entry,
+ "signal::icon-press", G_CALLBACK (icon_button_press_event_cb), lentry,
+ "signal::populate-popup", G_CALLBACK (entry_populate_popup_cb), lentry,
+ "signal::key-press-event", G_CALLBACK (entry_key_press_cb), lentry,
+ "signal::changed", G_CALLBACK (editable_changed_cb), lentry,
+ "signal::drag-motion", G_CALLBACK (entry_drag_motion_cb), lentry,
+ "signal::drag-drop", G_CALLBACK (entry_drag_drop_cb), lentry,
+ "signal::drag-data-get", G_CALLBACK (favicon_drag_data_get_cb), lentry,
+ NULL);
+
+ g_signal_connect_after (entry, "key-press-event",
+ G_CALLBACK (entry_key_press_after_cb), lentry);
+ g_signal_connect_after (entry, "activate",
+ G_CALLBACK (entry_activate_after_cb), lentry);
+ g_signal_connect_after (entry, "drag-begin",
+ G_CALLBACK (favicon_drag_begin_cb), lentry);
}
static void
ephy_location_entry_init (EphyLocationEntry *le)
{
- LOG ("EphyLocationEntry initialising %p", le);
+ LOG ("EphyLocationEntry initialising %p", le);
- le->user_changed = FALSE;
- le->block_update = FALSE;
- le->saved_text = NULL;
- le->show_favicon = TRUE;
- le->dns_prefetch_handler = 0;
+ le->user_changed = FALSE;
+ le->block_update = FALSE;
+ le->saved_text = NULL;
+ le->show_favicon = TRUE;
+ le->dns_prefetch_handler = 0;
- ephy_location_entry_construct_contents (le);
+ ephy_location_entry_construct_contents (le);
}
GtkWidget *
ephy_location_entry_new (void)
{
- return GTK_WIDGET (g_object_new (EPHY_TYPE_LOCATION_ENTRY, NULL));
+ return GTK_WIDGET (g_object_new (EPHY_TYPE_LOCATION_ENTRY, NULL));
}
#if 0
/* FIXME: Refactor the DNS prefetch, this is a layering violation */
typedef struct {
- SoupURI *uri;
- EphyLocationEntry *entry;
+ SoupURI *uri;
+ EphyLocationEntry *entry;
} PrefetchHelper;
static void
free_prefetch_helper (PrefetchHelper *helper)
{
- soup_uri_free (helper->uri);
- g_object_unref (helper->entry);
- g_slice_free (PrefetchHelper, helper);
+ soup_uri_free (helper->uri);
+ g_object_unref (helper->entry);
+ g_slice_free (PrefetchHelper, helper);
}
static gboolean
do_dns_prefetch (PrefetchHelper *helper)
{
- EphyEmbedShell *shell = ephy_embed_shell_get_default ();
+ EphyEmbedShell *shell = ephy_embed_shell_get_default ();
- if (helper->uri)
- webkit_web_context_prefetch_dns (ephy_embed_shell_get_web_context (shell), helper->uri->host);
+ if (helper->uri)
+ webkit_web_context_prefetch_dns (ephy_embed_shell_get_web_context (shell), helper->uri->host);
- helper->entry->dns_prefetch_handler = 0;
+ helper->entry->dns_prefetch_handler = 0;
- return FALSE;
+ return FALSE;
}
static void
schedule_dns_prefetch (EphyLocationEntry *entry, guint interval, const gchar *url)
{
- PrefetchHelper *helper;
- SoupURI *uri;
-
- uri = soup_uri_new (url);
- if (!uri || !uri->host) {
- soup_uri_free (uri);
- return;
- }
-
- if (entry->dns_prefetch_handler)
- g_source_remove (entry->dns_prefetch_handler);
-
- helper = g_slice_new0 (PrefetchHelper);
- helper->entry = g_object_ref (entry);
- helper->uri = uri;
-
- entry->dns_prefetch_handler =
- g_timeout_add_full (G_PRIORITY_DEFAULT, interval,
- (GSourceFunc) do_dns_prefetch, helper,
- (GDestroyNotify) free_prefetch_helper);
- g_source_set_name_by_id (entry->dns_prefetch_handler, "[epiphany] do_dns_prefetch");
+ PrefetchHelper *helper;
+ SoupURI *uri;
+
+ uri = soup_uri_new (url);
+ if (!uri || !uri->host) {
+ soup_uri_free (uri);
+ return;
+ }
+
+ if (entry->dns_prefetch_handler)
+ g_source_remove (entry->dns_prefetch_handler);
+
+ helper = g_slice_new0 (PrefetchHelper);
+ helper->entry = g_object_ref (entry);
+ helper->uri = uri;
+
+ entry->dns_prefetch_handler =
+ g_timeout_add_full (G_PRIORITY_DEFAULT, interval,
+ (GSourceFunc)do_dns_prefetch, helper,
+ (GDestroyNotify)free_prefetch_helper);
+ g_source_set_name_by_id (entry->dns_prefetch_handler, "[epiphany] do_dns_prefetch");
}
#endif
static gboolean
-cursor_on_match_cb (GtkEntryCompletion *completion,
- GtkTreeModel *model,
- GtkTreeIter *iter,
- EphyLocationEntry *le)
+cursor_on_match_cb (GtkEntryCompletion *completion,
+ GtkTreeModel *model,
+ GtkTreeIter *iter,
+ EphyLocationEntry *le)
{
- char *url = NULL;
- GtkWidget *entry;
-
- gtk_tree_model_get (model, iter,
- le->url_col,
- &url, -1);
- entry = gtk_entry_completion_get_entry (completion);
-
- /* Prevent the update so we keep the highlight from our input.
- * See textcell_data_func().
- */
- le->block_update = TRUE;
- gtk_entry_set_text (GTK_ENTRY (entry), url);
- gtk_editable_set_position (GTK_EDITABLE (entry), -1);
- le->block_update = FALSE;
+ char *url = NULL;
+ GtkWidget *entry;
+
+ gtk_tree_model_get (model, iter,
+ le->url_col,
+ &url, -1);
+ entry = gtk_entry_completion_get_entry (completion);
+
+ /* Prevent the update so we keep the highlight from our input.
+ * See textcell_data_func().
+ */
+ le->block_update = TRUE;
+ gtk_entry_set_text (GTK_ENTRY (entry), url);
+ gtk_editable_set_position (GTK_EDITABLE (entry), -1);
+ le->block_update = FALSE;
#if 0
/* FIXME: Refactor the DNS prefetch, this is a layering violation */
- schedule_dns_prefetch (le, 250, (const gchar*) url);
+ schedule_dns_prefetch (le, 250, (const gchar *)url);
#endif
- g_free (url);
+ g_free (url);
- return TRUE;
+ return TRUE;
}
static void
-extracell_data_func (GtkCellLayout *cell_layout,
- GtkCellRenderer *cell,
- GtkTreeModel *tree_model,
- GtkTreeIter *iter,
- gpointer data)
+extracell_data_func (GtkCellLayout *cell_layout,
+ GtkCellRenderer *cell,
+ GtkTreeModel *tree_model,
+ GtkTreeIter *iter,
+ gpointer data)
{
- EphyLocationEntry *entry = EPHY_LOCATION_ENTRY (data);
- gboolean is_bookmark = FALSE;
- GValue visible = { 0, };
-
- gtk_tree_model_get (tree_model, iter,
- entry->extra_col, &is_bookmark,
- -1);
-
- if (is_bookmark)
- g_object_set (cell,
- "icon-name", "user-bookmarks-symbolic",
- NULL);
-
- g_value_init (&visible, G_TYPE_BOOLEAN);
- g_value_set_boolean (&visible, is_bookmark);
- g_object_set_property (G_OBJECT (cell), "visible", &visible);
- g_value_unset (&visible);
+ EphyLocationEntry *entry = EPHY_LOCATION_ENTRY (data);
+ gboolean is_bookmark = FALSE;
+ GValue visible = { 0, };
+
+ gtk_tree_model_get (tree_model, iter,
+ entry->extra_col, &is_bookmark,
+ -1);
+
+ if (is_bookmark)
+ g_object_set (cell,
+ "icon-name", "user-bookmarks-symbolic",
+ NULL);
+
+ g_value_init (&visible, G_TYPE_BOOLEAN);
+ g_value_set_boolean (&visible, is_bookmark);
+ g_object_set_property (G_OBJECT (cell), "visible", &visible);
+ g_value_unset (&visible);
}
/**
@@ -1095,15 +1061,15 @@ extracell_data_func (GtkCellLayout *cell_layout,
*
**/
void
-ephy_location_entry_set_match_func (EphyLocationEntry *entry,
- GtkEntryCompletionMatchFunc match_func,
- gpointer user_data,
- GDestroyNotify notify)
+ephy_location_entry_set_match_func (EphyLocationEntry *entry,
+ GtkEntryCompletionMatchFunc match_func,
+ gpointer user_data,
+ GDestroyNotify notify)
{
- GtkEntryCompletion *completion;
+ GtkEntryCompletion *completion;
- completion = gtk_entry_get_completion (GTK_ENTRY (entry));
- gtk_entry_completion_set_match_func (completion, match_func, user_data, notify);
+ completion = gtk_entry_get_completion (GTK_ENTRY (entry));
+ gtk_entry_completion_set_match_func (completion, match_func, user_data, notify);
}
/**
@@ -1126,64 +1092,64 @@ ephy_location_entry_set_match_func (EphyLocationEntry *entry,
**/
void
ephy_location_entry_set_completion (EphyLocationEntry *entry,
- GtkTreeModel *model,
- guint text_col,
- guint action_col,
- guint keywords_col,
- guint relevance_col,
- guint url_col,
- guint extra_col,
- guint favicon_col)
+ GtkTreeModel *model,
+ guint text_col,
+ guint action_col,
+ guint keywords_col,
+ guint relevance_col,
+ guint url_col,
+ guint extra_col,
+ guint favicon_col)
{
- GtkEntryCompletion *completion;
- GtkCellRenderer *cell;
-
- entry->text_col = text_col;
- entry->action_col = action_col;
- entry->keywords_col = keywords_col;
- entry->relevance_col = relevance_col;
- entry->url_col = url_col;
- entry->extra_col = extra_col;
- entry->favicon_col = favicon_col;
-
- completion = gtk_entry_completion_new ();
- gtk_entry_completion_set_model (completion, model);
- g_signal_connect (completion, "match-selected",
- G_CALLBACK (match_selected_cb), entry);
- g_signal_connect_after (completion, "action-activated",
- G_CALLBACK (action_activated_after_cb), entry);
-
- cell = gtk_cell_renderer_pixbuf_new ();
- gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (completion),
- cell, FALSE);
- gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (completion),
- cell, "pixbuf", favicon_col);
-
- /* Pixel-perfect aligment with the location entry favicon
- * (16x16). Consider that this /might/ depend on the theme.
- *
- * The GtkEntryCompletion can not be themed so we work-around
- * that with padding and fixed sizes.
- * For the first cell, this is:
- *
- * ___+++++iiiiiiiiiiiiiiii++__ttt...bbb++++++__
- *
- * _ = widget spacing, can not be handled (3 px)
- * + = padding (5 px) (ICON_PADDING_LEFT)
- * i = the icon (16 px) (ICON_CONTENT_WIDTH)
- * + = padding (2 px) (ICON_PADDING_RIGHT) (cut by the fixed_size)
- * _ = spacing between cells, can not be handled (2 px)
- * t = the text (expands)
- * b = bookmark icon (16 px)
- * + = padding (6 px) (BKMK_PADDING_RIGHT)
- * _ = widget spacing, can not be handled (2 px)
- *
- * Each character is a pixel.
- *
- * The text cell and the bookmark icon cell are much more
- * flexible in its aligment, because they do not have to align
- * with anything in the entry.
- */
+ GtkEntryCompletion *completion;
+ GtkCellRenderer *cell;
+
+ entry->text_col = text_col;
+ entry->action_col = action_col;
+ entry->keywords_col = keywords_col;
+ entry->relevance_col = relevance_col;
+ entry->url_col = url_col;
+ entry->extra_col = extra_col;
+ entry->favicon_col = favicon_col;
+
+ completion = gtk_entry_completion_new ();
+ gtk_entry_completion_set_model (completion, model);
+ g_signal_connect (completion, "match-selected",
+ G_CALLBACK (match_selected_cb), entry);
+ g_signal_connect_after (completion, "action-activated",
+ G_CALLBACK (action_activated_after_cb), entry);
+
+ cell = gtk_cell_renderer_pixbuf_new ();
+ gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (completion),
+ cell, FALSE);
+ gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (completion),
+ cell, "pixbuf", favicon_col);
+
+ /* Pixel-perfect aligment with the location entry favicon
+ * (16x16). Consider that this /might/ depend on the theme.
+ *
+ * The GtkEntryCompletion can not be themed so we work-around
+ * that with padding and fixed sizes.
+ * For the first cell, this is:
+ *
+ * ___+++++iiiiiiiiiiiiiiii++__ttt...bbb++++++__
+ *
+ * _ = widget spacing, can not be handled (3 px)
+ * + = padding (5 px) (ICON_PADDING_LEFT)
+ * i = the icon (16 px) (ICON_CONTENT_WIDTH)
+ * + = padding (2 px) (ICON_PADDING_RIGHT) (cut by the fixed_size)
+ * _ = spacing between cells, can not be handled (2 px)
+ * t = the text (expands)
+ * b = bookmark icon (16 px)
+ * + = padding (6 px) (BKMK_PADDING_RIGHT)
+ * _ = widget spacing, can not be handled (2 px)
+ *
+ * Each character is a pixel.
+ *
+ * The text cell and the bookmark icon cell are much more
+ * flexible in its aligment, because they do not have to align
+ * with anything in the entry.
+ */
#define ROW_PADDING_VERT 4
@@ -1197,64 +1163,64 @@ ephy_location_entry_set_completion (EphyLocationEntry *entry,
#define BKMK_PADDING_RIGHT 6
- gtk_cell_renderer_set_padding
- (cell, ICON_PADDING_LEFT, ROW_PADDING_VERT);
- gtk_cell_renderer_set_fixed_size
- (cell,
- (ICON_PADDING_LEFT + ICON_CONTENT_WIDTH + ICON_PADDING_RIGHT),
- ICON_CONTENT_HEIGHT);
- gtk_cell_renderer_set_alignment (cell, 0.0, 0.5);
-
- cell = gd_two_lines_renderer_new ();
- g_object_set (cell,
- "ellipsize", PANGO_ELLIPSIZE_END,
- "text-lines", 2,
- NULL);
- gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (completion),
- cell, TRUE);
- gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (completion),
- cell, "text", text_col);
- gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (completion),
- cell, "line-two", url_col);
-
- /* Pixel-perfect aligment with the text in the location entry.
- * See above.
- */
- gtk_cell_renderer_set_padding
- (cell, TEXT_PADDING_LEFT, ROW_PADDING_VERT);
- gtk_cell_renderer_set_alignment (cell, 0.0, 0.5);
-
- /*
- * As the width of the entry completion is known in advance
- * (as big as the entry you are completing on), we can set
- * any fixed width (the 1 is just this random number here)
- * Since the height is known too, we avoid computing the actual
- * sizes of the cells, which takes a lot of CPU time and does
- * not get used anyway.
- */
- gtk_cell_renderer_set_fixed_size (cell, 1, -1);
- gtk_cell_renderer_text_set_fixed_height_from_font (GTK_CELL_RENDERER_TEXT (cell), 2);
-
- cell = gtk_cell_renderer_pixbuf_new ();
- g_object_set (cell, "follow-state", TRUE, NULL);
- gtk_cell_layout_pack_end (GTK_CELL_LAYOUT (completion),
- cell, FALSE);
- gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (completion),
- cell, extracell_data_func,
- entry,
- NULL);
-
- /* Pixel-perfect aligment. This just keeps the same margin from
- * the border than the favicon on the other side. See above. */
- gtk_cell_renderer_set_padding
- (cell, BKMK_PADDING_RIGHT, ROW_PADDING_VERT);
-
- g_object_set (completion, "inline-selection", TRUE, NULL);
- g_signal_connect (completion, "cursor-on-match",
- G_CALLBACK (cursor_on_match_cb), entry);
-
- gtk_entry_set_completion (GTK_ENTRY (entry), completion);
- g_object_unref (completion);
+ gtk_cell_renderer_set_padding
+ (cell, ICON_PADDING_LEFT, ROW_PADDING_VERT);
+ gtk_cell_renderer_set_fixed_size
+ (cell,
+ (ICON_PADDING_LEFT + ICON_CONTENT_WIDTH + ICON_PADDING_RIGHT),
+ ICON_CONTENT_HEIGHT);
+ gtk_cell_renderer_set_alignment (cell, 0.0, 0.5);
+
+ cell = gd_two_lines_renderer_new ();
+ g_object_set (cell,
+ "ellipsize", PANGO_ELLIPSIZE_END,
+ "text-lines", 2,
+ NULL);
+ gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (completion),
+ cell, TRUE);
+ gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (completion),
+ cell, "text", text_col);
+ gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (completion),
+ cell, "line-two", url_col);
+
+ /* Pixel-perfect aligment with the text in the location entry.
+ * See above.
+ */
+ gtk_cell_renderer_set_padding
+ (cell, TEXT_PADDING_LEFT, ROW_PADDING_VERT);
+ gtk_cell_renderer_set_alignment (cell, 0.0, 0.5);
+
+ /*
+ * As the width of the entry completion is known in advance
+ * (as big as the entry you are completing on), we can set
+ * any fixed width (the 1 is just this random number here)
+ * Since the height is known too, we avoid computing the actual
+ * sizes of the cells, which takes a lot of CPU time and does
+ * not get used anyway.
+ */
+ gtk_cell_renderer_set_fixed_size (cell, 1, -1);
+ gtk_cell_renderer_text_set_fixed_height_from_font (GTK_CELL_RENDERER_TEXT (cell), 2);
+
+ cell = gtk_cell_renderer_pixbuf_new ();
+ g_object_set (cell, "follow-state", TRUE, NULL);
+ gtk_cell_layout_pack_end (GTK_CELL_LAYOUT (completion),
+ cell, FALSE);
+ gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (completion),
+ cell, extracell_data_func,
+ entry,
+ NULL);
+
+ /* Pixel-perfect aligment. This just keeps the same margin from
+ * the border than the favicon on the other side. See above. */
+ gtk_cell_renderer_set_padding
+ (cell, BKMK_PADDING_RIGHT, ROW_PADDING_VERT);
+
+ g_object_set (completion, "inline-selection", TRUE, NULL);
+ g_signal_connect (completion, "cursor-on-match",
+ G_CALLBACK (cursor_on_match_cb), entry);
+
+ gtk_entry_set_completion (GTK_ENTRY (entry), completion);
+ g_object_unref (completion);
}
/**
@@ -1266,76 +1232,70 @@ ephy_location_entry_set_completion (EphyLocationEntry *entry,
**/
void
ephy_location_entry_set_location (EphyLocationEntry *entry,
- const char *address)
+ const char *address)
{
- GtkWidget *widget = GTK_WIDGET (entry);
- GtkClipboard *clipboard;
- const char *text;
- char *effective_text = NULL, *selection = NULL;
- int start, end;
-
- /* Setting a new text will clear the clipboard. This makes it impossible
- * to copy&paste from the location entry of one tab into another tab, see
- * bug #155824. So we save the selection iff the clipboard was owned by
- * the location entry.
- */
- if (gtk_widget_get_realized (widget))
- {
- clipboard = gtk_widget_get_clipboard (widget,
- GDK_SELECTION_PRIMARY);
- g_return_if_fail (clipboard != NULL);
-
- if (gtk_clipboard_get_owner (clipboard) == G_OBJECT (widget) &&
- gtk_editable_get_selection_bounds (GTK_EDITABLE (widget),
- &start, &end))
- {
- selection = gtk_editable_get_chars (GTK_EDITABLE (widget),
- start, end);
- }
- }
-
- if (address != NULL)
- {
- if (g_str_has_prefix (address, EPHY_ABOUT_SCHEME))
- effective_text = g_strdup_printf ("about:%s",
- address + strlen (EPHY_ABOUT_SCHEME) + 1);
- text = address;
- gtk_entry_set_icon_drag_source (GTK_ENTRY (entry),
- GTK_ENTRY_ICON_PRIMARY,
- entry->drag_targets,
- entry->drag_actions);
- }
- else
- {
- text = "";
- gtk_entry_set_icon_drag_source (GTK_ENTRY (entry),
- GTK_ENTRY_ICON_PRIMARY,
- NULL,
- GDK_ACTION_DEFAULT);
- }
-
- /* First record the new hash, then update the entry text */
- entry->hash = g_str_hash (effective_text ? effective_text : text);
-
- entry->block_update = TRUE;
- gtk_entry_set_text (GTK_ENTRY (widget), effective_text ? effective_text : text);
- entry->block_update = FALSE;
- g_free (effective_text);
-
- /* We need to call update_address_state() here, as the 'changed' signal
- * may not get called if the user has typed in the exact correct url */
- update_address_state (entry);
- update_favicon (entry);
-
- /* Now restore the selection.
- * Note that it's not owned by the entry anymore!
- */
- if (selection != NULL)
- {
- gtk_clipboard_set_text (gtk_clipboard_get (GDK_SELECTION_PRIMARY),
- selection, strlen (selection));
- g_free (selection);
- }
+ GtkWidget *widget = GTK_WIDGET (entry);
+ GtkClipboard *clipboard;
+ const char *text;
+ char *effective_text = NULL, *selection = NULL;
+ int start, end;
+
+ /* Setting a new text will clear the clipboard. This makes it impossible
+ * to copy&paste from the location entry of one tab into another tab, see
+ * bug #155824. So we save the selection iff the clipboard was owned by
+ * the location entry.
+ */
+ if (gtk_widget_get_realized (widget)) {
+ clipboard = gtk_widget_get_clipboard (widget,
+ GDK_SELECTION_PRIMARY);
+ g_return_if_fail (clipboard != NULL);
+
+ if (gtk_clipboard_get_owner (clipboard) == G_OBJECT (widget) &&
+ gtk_editable_get_selection_bounds (GTK_EDITABLE (widget),
+ &start, &end)) {
+ selection = gtk_editable_get_chars (GTK_EDITABLE (widget),
+ start, end);
+ }
+ }
+
+ if (address != NULL) {
+ if (g_str_has_prefix (address, EPHY_ABOUT_SCHEME))
+ effective_text = g_strdup_printf ("about:%s",
+ address + strlen (EPHY_ABOUT_SCHEME) + 1);
+ text = address;
+ gtk_entry_set_icon_drag_source (GTK_ENTRY (entry),
+ GTK_ENTRY_ICON_PRIMARY,
+ entry->drag_targets,
+ entry->drag_actions);
+ } else {
+ text = "";
+ gtk_entry_set_icon_drag_source (GTK_ENTRY (entry),
+ GTK_ENTRY_ICON_PRIMARY,
+ NULL,
+ GDK_ACTION_DEFAULT);
+ }
+
+ /* First record the new hash, then update the entry text */
+ entry->hash = g_str_hash (effective_text ? effective_text : text);
+
+ entry->block_update = TRUE;
+ gtk_entry_set_text (GTK_ENTRY (widget), effective_text ? effective_text : text);
+ entry->block_update = FALSE;
+ g_free (effective_text);
+
+ /* We need to call update_address_state() here, as the 'changed' signal
+ * may not get called if the user has typed in the exact correct url */
+ update_address_state (entry);
+ update_favicon (entry);
+
+ /* Now restore the selection.
+ * Note that it's not owned by the entry anymore!
+ */
+ if (selection != NULL) {
+ gtk_clipboard_set_text (gtk_clipboard_get (GDK_SELECTION_PRIMARY),
+ selection, strlen (selection));
+ g_free (selection);
+ }
}
/**
@@ -1351,7 +1311,7 @@ ephy_location_entry_set_location (EphyLocationEntry *entry,
gboolean
ephy_location_entry_get_can_undo (EphyLocationEntry *entry)
{
- return entry->user_changed;
+ return entry->user_changed;
}
/**
@@ -1367,7 +1327,7 @@ ephy_location_entry_get_can_undo (EphyLocationEntry *entry)
gboolean
ephy_location_entry_get_can_redo (EphyLocationEntry *entry)
{
- return entry->can_redo;
+ return entry->can_redo;
}
/**
@@ -1383,39 +1343,38 @@ ephy_location_entry_get_can_redo (EphyLocationEntry *entry)
const char *
ephy_location_entry_get_location (EphyLocationEntry *entry)
{
- return gtk_entry_get_text (GTK_ENTRY (entry));
+ return gtk_entry_get_text (GTK_ENTRY (entry));
}
static gboolean
ephy_location_entry_reset_internal (EphyLocationEntry *entry,
- gboolean notify)
+ gboolean notify)
{
- const char *text, *old_text;
- char *url = NULL;
- gboolean retval;
+ const char *text, *old_text;
+ char *url = NULL;
+ gboolean retval;
- g_signal_emit (entry, signals[GET_LOCATION], 0, &url);
- text = url != NULL ? url : "";
- old_text = gtk_entry_get_text (GTK_ENTRY (entry));
- old_text = old_text != NULL ? old_text : "";
+ g_signal_emit (entry, signals[GET_LOCATION], 0, &url);
+ text = url != NULL ? url : "";
+ old_text = gtk_entry_get_text (GTK_ENTRY (entry));
+ old_text = old_text != NULL ? old_text : "";
- g_free (entry->saved_text);
- entry->saved_text = g_strdup (old_text);
- entry->can_redo = TRUE;
+ g_free (entry->saved_text);
+ entry->saved_text = g_strdup (old_text);
+ entry->can_redo = TRUE;
- retval = g_str_hash (text) != g_str_hash (old_text);
+ retval = g_str_hash (text) != g_str_hash (old_text);
- ephy_location_entry_set_location (entry, text);
- g_free (url);
+ ephy_location_entry_set_location (entry, text);
+ g_free (url);
- if (notify)
- {
- g_signal_emit (entry, signals[USER_CHANGED], 0);
- }
+ if (notify) {
+ g_signal_emit (entry, signals[USER_CHANGED], 0);
+ }
- entry->user_changed = FALSE;
+ entry->user_changed = FALSE;
- return retval;
+ return retval;
}
/**
@@ -1428,9 +1387,9 @@ ephy_location_entry_reset_internal (EphyLocationEntry *entry,
void
ephy_location_entry_undo_reset (EphyLocationEntry *entry)
{
- gtk_entry_set_text (GTK_ENTRY (entry), entry->saved_text);
- entry->can_redo = FALSE;
- entry->user_changed = TRUE;
+ gtk_entry_set_text (GTK_ENTRY (entry), entry->saved_text);
+ entry->can_redo = FALSE;
+ entry->user_changed = TRUE;
}
/**
@@ -1447,7 +1406,7 @@ ephy_location_entry_undo_reset (EphyLocationEntry *entry)
gboolean
ephy_location_entry_reset (EphyLocationEntry *entry)
{
- return ephy_location_entry_reset_internal (entry, FALSE);
+ return ephy_location_entry_reset_internal (entry, FALSE);
}
/**
@@ -1461,14 +1420,14 @@ ephy_location_entry_reset (EphyLocationEntry *entry)
void
ephy_location_entry_activate (EphyLocationEntry *entry)
{
- GtkWidget *toplevel, *widget = GTK_WIDGET (entry);
+ GtkWidget *toplevel, *widget = GTK_WIDGET (entry);
- toplevel = gtk_widget_get_toplevel (widget);
+ toplevel = gtk_widget_get_toplevel (widget);
- gtk_editable_select_region (GTK_EDITABLE (entry),
- 0, -1);
- gtk_window_set_focus (GTK_WINDOW (toplevel),
- widget);
+ gtk_editable_select_region (GTK_EDITABLE (entry),
+ 0, -1);
+ gtk_window_set_focus (GTK_WINDOW (toplevel),
+ widget);
}
/**
@@ -1481,27 +1440,26 @@ ephy_location_entry_activate (EphyLocationEntry *entry)
**/
void
ephy_location_entry_set_favicon (EphyLocationEntry *entry,
- GdkPixbuf *pixbuf)
+ GdkPixbuf *pixbuf)
{
- if (entry->favicon != NULL)
- {
- g_object_unref (entry->favicon);
- }
+ if (entry->favicon != NULL) {
+ g_object_unref (entry->favicon);
+ }
- entry->favicon = pixbuf ? g_object_ref (pixbuf) : NULL;
+ entry->favicon = pixbuf ? g_object_ref (pixbuf) : NULL;
- update_favicon (entry);
+ update_favicon (entry);
}
void
ephy_location_entry_set_show_favicon (EphyLocationEntry *entry,
- gboolean show_favicon)
+ gboolean show_favicon)
{
- g_return_if_fail (EPHY_IS_LOCATION_ENTRY (entry));
+ g_return_if_fail (EPHY_IS_LOCATION_ENTRY (entry));
- entry->show_favicon = show_favicon != FALSE;
+ entry->show_favicon = show_favicon != FALSE;
- update_favicon (entry);
+ update_favicon (entry);
}
/**
@@ -1514,17 +1472,17 @@ ephy_location_entry_set_show_favicon (EphyLocationEntry *entry,
**/
void
ephy_location_entry_set_security_level (EphyLocationEntry *entry,
- EphySecurityLevel security_level)
+ EphySecurityLevel security_level)
{
- const char *icon_name;
+ const char *icon_name;
- g_return_if_fail (EPHY_IS_LOCATION_ENTRY (entry));
+ g_return_if_fail (EPHY_IS_LOCATION_ENTRY (entry));
- icon_name = ephy_security_level_to_icon_name (security_level);
- gtk_entry_set_icon_from_icon_name (GTK_ENTRY (entry),
- GTK_ENTRY_ICON_SECONDARY,
- icon_name);
+ icon_name = ephy_security_level_to_icon_name (security_level);
+ gtk_entry_set_icon_from_icon_name (GTK_ENTRY (entry),
+ GTK_ENTRY_ICON_SECONDARY,
+ icon_name);
}
/**
@@ -1537,11 +1495,11 @@ ephy_location_entry_set_security_level (EphyLocationEntry *entry,
**/
void
ephy_location_entry_set_lock_tooltip (EphyLocationEntry *entry,
- const char *tooltip)
+ const char *tooltip)
{
- gtk_entry_set_icon_tooltip_text (GTK_ENTRY (entry),
- GTK_ENTRY_ICON_SECONDARY,
- tooltip);
+ gtk_entry_set_icon_tooltip_text (GTK_ENTRY (entry),
+ GTK_ENTRY_ICON_SECONDARY,
+ tooltip);
}
/**
@@ -1557,5 +1515,5 @@ ephy_location_entry_set_lock_tooltip (EphyLocationEntry *entry,
GSList *
ephy_location_entry_get_search_terms (EphyLocationEntry *entry)
{
- return entry->search_terms;
+ return entry->search_terms;
}
diff --git a/lib/widgets/ephy-middle-clickable-button.c b/lib/widgets/ephy-middle-clickable-button.c
index aa7ad5526..c9bf47807 100644
--- a/lib/widgets/ephy-middle-clickable-button.c
+++ b/lib/widgets/ephy-middle-clickable-button.c
@@ -20,16 +20,15 @@
#include "config.h"
#include "ephy-middle-clickable-button.h"
-struct _EphyMiddleClickableButton
-{
+struct _EphyMiddleClickableButton {
GtkButton parent_instance;
};
G_DEFINE_TYPE (EphyMiddleClickableButton, ephy_middle_clickable_button, GTK_TYPE_BUTTON)
-static gboolean
-ephy_middle_clickable_button_handle_event (GtkWidget * widget,
- GdkEventButton * event)
+static gboolean
+ephy_middle_clickable_button_handle_event (GtkWidget *widget,
+ GdkEventButton *event)
{
gboolean ret;
int actual_button;
@@ -44,7 +43,7 @@ ephy_middle_clickable_button_handle_event (GtkWidget * widget,
ret = widget_class->button_press_event (widget, event);
else
ret = widget_class->button_release_event (widget, event);
-
+
event->button = actual_button;
return ret;
diff --git a/lib/widgets/ephy-node-view.c b/lib/widgets/ephy-node-view.c
index efc2213f3..f9361f5dc 100644
--- a/lib/widgets/ephy-node-view.c
+++ b/lib/widgets/ephy-node-view.c
@@ -1,5 +1,5 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
+/*
* Copyright © 2002 Jorn Baayen <jorn@nl.linux.org>
*
* This program is free software; you can redistribute it and/or modify
@@ -36,63 +36,60 @@
* elements. It implements drag and dropping.
*/
-struct _EphyNodeView
-{
- GtkTreeView parent_instance;
+struct _EphyNodeView {
+ GtkTreeView parent_instance;
- EphyNode *root;
+ EphyNode *root;
- EphyTreeModelNode *nodemodel;
- GtkTreeModel *filtermodel;
- GtkTreeModel *sortmodel;
- GtkCellRenderer *editable_renderer;
- GtkTreeViewColumn *editable_column;
- int editable_node_column;
- int toggle_column;
+ EphyTreeModelNode *nodemodel;
+ GtkTreeModel *filtermodel;
+ GtkTreeModel *sortmodel;
+ GtkCellRenderer *editable_renderer;
+ GtkTreeViewColumn *editable_column;
+ int editable_node_column;
+ int toggle_column;
- EphyNodeFilter *filter;
+ EphyNodeFilter *filter;
- GtkTargetList *drag_targets;
+ GtkTargetList *drag_targets;
- int sort_column;
- GtkSortType sort_type;
- guint priority_prop_id;
- int priority_column;
+ int sort_column;
+ GtkSortType sort_type;
+ guint priority_prop_id;
+ int priority_column;
- EphyNode *edited_node;
- gboolean remove_if_cancelled;
- int editable_property;
+ EphyNode *edited_node;
+ gboolean remove_if_cancelled;
+ int editable_property;
- gboolean drag_started;
- int drag_button;
- int drag_x;
- int drag_y;
- GtkTargetList *source_target_list;
+ gboolean drag_started;
+ int drag_button;
+ int drag_x;
+ int drag_y;
+ GtkTargetList *source_target_list;
- gboolean drop_occurred;
- gboolean have_drag_data;
- GtkSelectionData *drag_data;
- guint scroll_id;
+ gboolean drop_occurred;
+ gboolean have_drag_data;
+ GtkSelectionData *drag_data;
+ guint scroll_id;
- guint changing_selection : 1;
+ guint changing_selection : 1;
};
-enum
-{
- NODE_TOGGLED,
- NODE_ACTIVATED,
- NODE_SELECTED,
- NODE_DROPPED,
- NODE_MIDDLE_CLICKED,
- LAST_SIGNAL
+enum {
+ NODE_TOGGLED,
+ NODE_ACTIVATED,
+ NODE_SELECTED,
+ NODE_DROPPED,
+ NODE_MIDDLE_CLICKED,
+ LAST_SIGNAL
};
-enum
-{
- PROP_0,
- PROP_ROOT,
- PROP_FILTER,
- LAST_PROP
+enum {
+ PROP_0,
+ PROP_ROOT,
+ PROP_FILTER,
+ LAST_PROP
};
static GParamSpec *obj_properties[LAST_PROP];
@@ -106,321 +103,297 @@ G_DEFINE_TYPE (EphyNodeView, ephy_node_view, GTK_TYPE_TREE_VIEW)
static void
ephy_node_view_finalize (GObject *object)
{
- EphyNodeView *view = EPHY_NODE_VIEW (object);
+ EphyNodeView *view = EPHY_NODE_VIEW (object);
- g_object_unref (view->sortmodel);
- g_object_unref (view->filtermodel);
- g_object_unref (view->nodemodel);
+ g_object_unref (view->sortmodel);
+ g_object_unref (view->filtermodel);
+ g_object_unref (view->nodemodel);
- if (view->source_target_list)
- {
- gtk_target_list_unref (view->source_target_list);
- }
+ if (view->source_target_list) {
+ gtk_target_list_unref (view->source_target_list);
+ }
- if (view->drag_targets)
- {
- gtk_target_list_unref (view->drag_targets);
- }
+ if (view->drag_targets) {
+ gtk_target_list_unref (view->drag_targets);
+ }
- G_OBJECT_CLASS (ephy_node_view_parent_class)->finalize (object);
+ G_OBJECT_CLASS (ephy_node_view_parent_class)->finalize (object);
}
static EphyNode *
get_node_from_path (EphyNodeView *view, GtkTreePath *path)
{
- EphyNode *node;
- GtkTreeIter iter, iter2, iter3;
+ EphyNode *node;
+ GtkTreeIter iter, iter2, iter3;
- if (path == NULL) return NULL;
+ if (path == NULL) return NULL;
- gtk_tree_model_get_iter (view->sortmodel, &iter, path);
- gtk_tree_model_sort_convert_iter_to_child_iter
- (GTK_TREE_MODEL_SORT (view->sortmodel), &iter2, &iter);
+ gtk_tree_model_get_iter (view->sortmodel, &iter, path);
+ gtk_tree_model_sort_convert_iter_to_child_iter
+ (GTK_TREE_MODEL_SORT (view->sortmodel), &iter2, &iter);
- if (iter2.stamp == 0) {
- return NULL;
- }
- gtk_tree_model_filter_convert_iter_to_child_iter
- (GTK_TREE_MODEL_FILTER (view->filtermodel), &iter3, &iter2);
+ if (iter2.stamp == 0) {
+ return NULL;
+ }
+ gtk_tree_model_filter_convert_iter_to_child_iter
+ (GTK_TREE_MODEL_FILTER (view->filtermodel), &iter3, &iter2);
- node = ephy_tree_model_node_node_from_iter (view->nodemodel, &iter3);
+ node = ephy_tree_model_node_node_from_iter (view->nodemodel, &iter3);
- return node;
+ return node;
}
static void
gtk_tree_view_vertical_autoscroll (GtkTreeView *tree_view)
{
- GdkRectangle visible_rect;
- GtkAdjustment *vadjustment;
- GdkWindow *window;
- int y;
- int offset;
- float value;
-
- window = gtk_tree_view_get_bin_window (tree_view);
- vadjustment = gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (tree_view));
-
- gdk_window_get_device_position (window,
- gdk_device_manager_get_client_pointer (
- gdk_display_get_device_manager (
- gtk_widget_get_display (GTK_WIDGET (tree_view)))),
- NULL, &y, NULL);
-
- y += gtk_adjustment_get_value (vadjustment);
-
- gtk_tree_view_get_visible_rect (tree_view, &visible_rect);
-
- offset = y - (visible_rect.y + 2 * AUTO_SCROLL_MARGIN);
- if (offset > 0)
- {
- offset = y - (visible_rect.y + visible_rect.height - 2 * AUTO_SCROLL_MARGIN);
- if (offset < 0)
- {
- return;
- }
- }
-
- value = CLAMP (gtk_adjustment_get_value (vadjustment) + offset, 0.0,
- gtk_adjustment_get_upper (vadjustment) - gtk_adjustment_get_page_size (vadjustment));
- gtk_adjustment_set_value (vadjustment, value);
+ GdkRectangle visible_rect;
+ GtkAdjustment *vadjustment;
+ GdkWindow *window;
+ int y;
+ int offset;
+ float value;
+
+ window = gtk_tree_view_get_bin_window (tree_view);
+ vadjustment = gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (tree_view));
+
+ gdk_window_get_device_position (window,
+ gdk_device_manager_get_client_pointer (
+ gdk_display_get_device_manager (
+ gtk_widget_get_display (GTK_WIDGET (tree_view)))),
+ NULL, &y, NULL);
+
+ y += gtk_adjustment_get_value (vadjustment);
+
+ gtk_tree_view_get_visible_rect (tree_view, &visible_rect);
+
+ offset = y - (visible_rect.y + 2 * AUTO_SCROLL_MARGIN);
+ if (offset > 0) {
+ offset = y - (visible_rect.y + visible_rect.height - 2 * AUTO_SCROLL_MARGIN);
+ if (offset < 0) {
+ return;
+ }
+ }
+
+ value = CLAMP (gtk_adjustment_get_value (vadjustment) + offset, 0.0,
+ gtk_adjustment_get_upper (vadjustment) - gtk_adjustment_get_page_size (vadjustment));
+ gtk_adjustment_set_value (vadjustment, value);
}
static int
scroll_timeout (gpointer data)
{
- GtkTreeView *tree_view = GTK_TREE_VIEW (data);
+ GtkTreeView *tree_view = GTK_TREE_VIEW (data);
- gtk_tree_view_vertical_autoscroll (tree_view);
+ gtk_tree_view_vertical_autoscroll (tree_view);
- return TRUE;
+ return TRUE;
}
static void
remove_scroll_timeout (EphyNodeView *view)
{
- if (view->scroll_id)
- {
- g_source_remove (view->scroll_id);
- view->scroll_id = 0;
- }
+ if (view->scroll_id) {
+ g_source_remove (view->scroll_id);
+ view->scroll_id = 0;
+ }
}
static void
set_drag_dest_row (EphyNodeView *view,
- GtkTreePath *path)
-{
- if (path)
- {
- gtk_tree_view_set_drag_dest_row
- (GTK_TREE_VIEW (view),
- path,
- GTK_TREE_VIEW_DROP_INTO_OR_BEFORE);
- }
- else
- {
- gtk_tree_view_set_drag_dest_row (GTK_TREE_VIEW (view),
- NULL,
- 0);
- }
+ GtkTreePath *path)
+{
+ if (path) {
+ gtk_tree_view_set_drag_dest_row
+ (GTK_TREE_VIEW (view),
+ path,
+ GTK_TREE_VIEW_DROP_INTO_OR_BEFORE);
+ } else {
+ gtk_tree_view_set_drag_dest_row (GTK_TREE_VIEW (view),
+ NULL,
+ 0);
+ }
}
static void
clear_drag_dest_row (EphyNodeView *view)
{
- gtk_tree_view_set_drag_dest_row (GTK_TREE_VIEW (view), NULL, 0);
+ gtk_tree_view_set_drag_dest_row (GTK_TREE_VIEW (view), NULL, 0);
}
static void
-get_drag_data (EphyNodeView *view,
- GdkDragContext *context,
- guint32 time)
+get_drag_data (EphyNodeView *view,
+ GdkDragContext *context,
+ guint32 time)
{
- GdkAtom target;
+ GdkAtom target;
- target = gtk_drag_dest_find_target (GTK_WIDGET (view),
- context,
- NULL);
+ target = gtk_drag_dest_find_target (GTK_WIDGET (view),
+ context,
+ NULL);
- gtk_drag_get_data (GTK_WIDGET (view),
- context, target, time);
+ gtk_drag_get_data (GTK_WIDGET (view),
+ context, target, time);
}
static void
free_drag_data (EphyNodeView *view)
{
- view->have_drag_data = FALSE;
+ view->have_drag_data = FALSE;
- if (view->drag_data)
- {
- gtk_selection_data_free (view->drag_data);
- view->drag_data = NULL;
- }
+ if (view->drag_data) {
+ gtk_selection_data_free (view->drag_data);
+ view->drag_data = NULL;
+ }
}
static gboolean
-drag_motion_cb (GtkWidget *widget,
- GdkDragContext *context,
- int x,
- int y,
- guint32 time,
- EphyNodeView *view)
-{
- EphyNode *node;
- GdkAtom target;
- GtkTreePath *path;
- GtkTreeViewDropPosition pos;
- guint action = 0;
- int priority;
-
- gtk_tree_view_get_dest_row_at_pos (GTK_TREE_VIEW (widget),
- x, y, &path, &pos);
-
- if (!view->have_drag_data)
- {
- get_drag_data (view, context, time);
- }
-
- target = gtk_drag_dest_find_target (widget, context, NULL);
- node = get_node_from_path (view, path);
-
- if (target != GDK_NONE && node != NULL)
- {
- priority = ephy_node_get_property_int (node, view->priority_prop_id);
-
- if (priority != EPHY_NODE_VIEW_ALL_PRIORITY &&
- priority != EPHY_NODE_VIEW_SPECIAL_PRIORITY &&
- ephy_node_get_is_drag_source (node))
- {
- action = gdk_drag_context_get_suggested_action (context);
- }
- }
-
- if (action)
- {
- set_drag_dest_row (view, path);
- }
- else
- {
- clear_drag_dest_row (view);
- }
-
- if (path)
- {
- gtk_tree_path_free (path);
- }
-
- if (view->scroll_id == 0)
- {
- view->scroll_id =
- g_timeout_add (150,
- scroll_timeout,
- GTK_TREE_VIEW (view));
- g_source_set_name_by_id (view->scroll_id, "[epiphany] scroll_timeout");
- }
-
- gdk_drag_status (context, action, time);
-
- return TRUE;
+drag_motion_cb (GtkWidget *widget,
+ GdkDragContext *context,
+ int x,
+ int y,
+ guint32 time,
+ EphyNodeView *view)
+{
+ EphyNode *node;
+ GdkAtom target;
+ GtkTreePath *path;
+ GtkTreeViewDropPosition pos;
+ guint action = 0;
+ int priority;
+
+ gtk_tree_view_get_dest_row_at_pos (GTK_TREE_VIEW (widget),
+ x, y, &path, &pos);
+
+ if (!view->have_drag_data) {
+ get_drag_data (view, context, time);
+ }
+
+ target = gtk_drag_dest_find_target (widget, context, NULL);
+ node = get_node_from_path (view, path);
+
+ if (target != GDK_NONE && node != NULL) {
+ priority = ephy_node_get_property_int (node, view->priority_prop_id);
+
+ if (priority != EPHY_NODE_VIEW_ALL_PRIORITY &&
+ priority != EPHY_NODE_VIEW_SPECIAL_PRIORITY &&
+ ephy_node_get_is_drag_source (node)) {
+ action = gdk_drag_context_get_suggested_action (context);
+ }
+ }
+
+ if (action) {
+ set_drag_dest_row (view, path);
+ } else {
+ clear_drag_dest_row (view);
+ }
+
+ if (path) {
+ gtk_tree_path_free (path);
+ }
+
+ if (view->scroll_id == 0) {
+ view->scroll_id =
+ g_timeout_add (150,
+ scroll_timeout,
+ GTK_TREE_VIEW (view));
+ g_source_set_name_by_id (view->scroll_id, "[epiphany] scroll_timeout");
+ }
+
+ gdk_drag_status (context, action, time);
+
+ return TRUE;
}
static void
-drag_leave_cb (GtkWidget *widget,
- GdkDragContext *context,
- guint32 time,
- EphyNodeView *view)
+drag_leave_cb (GtkWidget *widget,
+ GdkDragContext *context,
+ guint32 time,
+ EphyNodeView *view)
{
- clear_drag_dest_row (view);
+ clear_drag_dest_row (view);
- free_drag_data (view);
+ free_drag_data (view);
- remove_scroll_timeout (view);
+ remove_scroll_timeout (view);
}
static void
-drag_data_received_cb (GtkWidget *widget,
- GdkDragContext *context,
- int x,
- int y,
- GtkSelectionData *selection_data,
- guint info,
- guint32 time,
- EphyNodeView *view)
-{
- GtkTreeViewDropPosition pos;
-
- /* x and y here are valid only on drop ! */
-
- if ((gtk_selection_data_get_length (selection_data) <= 0) ||
- (gtk_selection_data_get_data (selection_data) == NULL))
- {
- return;
- }
-
- /* appease GtkTreeView by preventing its drag_data_receive
- * from being called */
- g_signal_stop_emission_by_name (view, "drag_data_received");
-
- if (!view->have_drag_data)
- {
- view->have_drag_data = TRUE;
- view->drag_data = gtk_selection_data_copy (selection_data);
- }
-
- if (view->drop_occurred)
- {
- EphyNode *node;
- char **uris;
- gboolean success = FALSE;
- GtkTreePath *path;
-
- if (gtk_tree_view_get_dest_row_at_pos
- (GTK_TREE_VIEW (widget), x, y, &path, &pos) == FALSE)
- {
- return;
- }
-
- node = get_node_from_path (view, path);
- if (node == NULL) return;
-
- uris = gtk_selection_data_get_uris (selection_data);
-
- if (uris != NULL && ephy_node_get_is_drag_dest (node))
- {
- /* FIXME fill success */
- g_signal_emit (G_OBJECT (view),
- ephy_node_view_signals[NODE_DROPPED], 0,
- node, uris);
- g_strfreev (uris);
-
- }
-
- view->drop_occurred = FALSE;
- free_drag_data (view);
- gtk_drag_finish (context, success, FALSE, time);
-
- if (path)
- {
- gtk_tree_path_free (path);
- }
- }
+drag_data_received_cb (GtkWidget *widget,
+ GdkDragContext *context,
+ int x,
+ int y,
+ GtkSelectionData *selection_data,
+ guint info,
+ guint32 time,
+ EphyNodeView *view)
+{
+ GtkTreeViewDropPosition pos;
+
+ /* x and y here are valid only on drop ! */
+
+ if ((gtk_selection_data_get_length (selection_data) <= 0) ||
+ (gtk_selection_data_get_data (selection_data) == NULL)) {
+ return;
+ }
+
+ /* appease GtkTreeView by preventing its drag_data_receive
+ * from being called */
+ g_signal_stop_emission_by_name (view, "drag_data_received");
+
+ if (!view->have_drag_data) {
+ view->have_drag_data = TRUE;
+ view->drag_data = gtk_selection_data_copy (selection_data);
+ }
+
+ if (view->drop_occurred) {
+ EphyNode *node;
+ char **uris;
+ gboolean success = FALSE;
+ GtkTreePath *path;
+
+ if (gtk_tree_view_get_dest_row_at_pos
+ (GTK_TREE_VIEW (widget), x, y, &path, &pos) == FALSE) {
+ return;
+ }
+
+ node = get_node_from_path (view, path);
+ if (node == NULL) return;
+
+ uris = gtk_selection_data_get_uris (selection_data);
+
+ if (uris != NULL && ephy_node_get_is_drag_dest (node)) {
+ /* FIXME fill success */
+ g_signal_emit (G_OBJECT (view),
+ ephy_node_view_signals[NODE_DROPPED], 0,
+ node, uris);
+ g_strfreev (uris);
+ }
+
+ view->drop_occurred = FALSE;
+ free_drag_data (view);
+ gtk_drag_finish (context, success, FALSE, time);
+
+ if (path) {
+ gtk_tree_path_free (path);
+ }
+ }
}
static gboolean
-drag_drop_cb (GtkWidget *widget,
- GdkDragContext *context,
- int x,
- int y,
- guint32 time,
- EphyNodeView *view)
+drag_drop_cb (GtkWidget *widget,
+ GdkDragContext *context,
+ int x,
+ int y,
+ guint32 time,
+ EphyNodeView *view)
{
- view->drop_occurred = TRUE;
+ view->drop_occurred = TRUE;
- get_drag_data (view, context, time);
- remove_scroll_timeout (view);
- clear_drag_dest_row (view);
+ get_drag_data (view, context, time);
+ remove_scroll_timeout (view);
+ clear_drag_dest_row (view);
- return TRUE;
+ return TRUE;
}
/**
@@ -433,526 +406,490 @@ drag_drop_cb (GtkWidget *widget,
*
**/
void
-ephy_node_view_enable_drag_dest (EphyNodeView *view,
- const GtkTargetEntry *types,
- int n_types)
+ephy_node_view_enable_drag_dest (EphyNodeView *view,
+ const GtkTargetEntry *types,
+ int n_types)
{
- GtkWidget *treeview;
+ GtkWidget *treeview;
- g_return_if_fail (view != NULL);
+ g_return_if_fail (view != NULL);
- treeview = GTK_WIDGET (view);
+ treeview = GTK_WIDGET (view);
- gtk_drag_dest_set (GTK_WIDGET (treeview),
- 0, types, n_types,
- GDK_ACTION_COPY);
- view->drag_targets = gtk_target_list_new (types, n_types);
+ gtk_drag_dest_set (GTK_WIDGET (treeview),
+ 0, types, n_types,
+ GDK_ACTION_COPY);
+ view->drag_targets = gtk_target_list_new (types, n_types);
- g_signal_connect (treeview, "drag_data_received",
- G_CALLBACK (drag_data_received_cb), view);
- g_signal_connect (treeview, "drag_drop",
- G_CALLBACK (drag_drop_cb), view);
- g_signal_connect (treeview, "drag_motion",
- G_CALLBACK (drag_motion_cb), view);
- g_signal_connect (treeview, "drag_leave",
- G_CALLBACK (drag_leave_cb), view);
+ g_signal_connect (treeview, "drag_data_received",
+ G_CALLBACK (drag_data_received_cb), view);
+ g_signal_connect (treeview, "drag_drop",
+ G_CALLBACK (drag_drop_cb), view);
+ g_signal_connect (treeview, "drag_motion",
+ G_CALLBACK (drag_motion_cb), view);
+ g_signal_connect (treeview, "drag_leave",
+ G_CALLBACK (drag_leave_cb), view);
}
static void
filter_changed_cb (EphyNodeFilter *filter,
- EphyNodeView *view)
+ EphyNodeView *view)
{
- GtkWidget *window;
- GdkWindow *gdk_window;
+ GtkWidget *window;
+ GdkWindow *gdk_window;
- g_return_if_fail (EPHY_IS_NODE_VIEW (view));
+ g_return_if_fail (EPHY_IS_NODE_VIEW (view));
- window = gtk_widget_get_toplevel (GTK_WIDGET (view));
- gdk_window = gtk_widget_get_window (window);
+ window = gtk_widget_get_toplevel (GTK_WIDGET (view));
+ gdk_window = gtk_widget_get_window (window);
- if (window != NULL && gdk_window != NULL)
- {
- /* nice busy cursor */
- GdkCursor *cursor;
+ if (window != NULL && gdk_window != NULL) {
+ /* nice busy cursor */
+ GdkCursor *cursor;
- cursor = gdk_cursor_new (GDK_WATCH);
- gdk_window_set_cursor (gdk_window, cursor);
- g_object_unref (cursor);
+ cursor = gdk_cursor_new (GDK_WATCH);
+ gdk_window_set_cursor (gdk_window, cursor);
+ g_object_unref (cursor);
- gdk_flush ();
+ gdk_flush ();
- gdk_window_set_cursor (gdk_window, NULL);
+ gdk_window_set_cursor (gdk_window, NULL);
- /* no flush: this will cause the cursor to be reset
- * only when the UI is free again */
- }
+ /* no flush: this will cause the cursor to be reset
+ * only when the UI is free again */
+ }
- gtk_tree_model_filter_refilter
- (GTK_TREE_MODEL_FILTER (view->filtermodel));
+ gtk_tree_model_filter_refilter
+ (GTK_TREE_MODEL_FILTER (view->filtermodel));
}
static void
ephy_node_view_selection_changed_cb (GtkTreeSelection *selection,
- EphyNodeView *view)
+ EphyNodeView *view)
{
- GList *list;
- EphyNode *node = NULL;
+ GList *list;
+ EphyNode *node = NULL;
- /* Work around bug #346662 */
- if (view->changing_selection) return;
+ /* Work around bug #346662 */
+ if (view->changing_selection) return;
- list = ephy_node_view_get_selection (view);
- if (list)
- {
- node = list->data;
- }
- g_list_free (list);
+ list = ephy_node_view_get_selection (view);
+ if (list) {
+ node = list->data;
+ }
+ g_list_free (list);
- g_signal_emit (G_OBJECT (view), ephy_node_view_signals[NODE_SELECTED], 0, node);
+ g_signal_emit (G_OBJECT (view), ephy_node_view_signals[NODE_SELECTED], 0, node);
}
static void
-ephy_node_view_row_activated_cb (GtkTreeView *treeview,
- GtkTreePath *path,
- GtkTreeViewColumn *column,
- EphyNodeView *view)
+ephy_node_view_row_activated_cb (GtkTreeView *treeview,
+ GtkTreePath *path,
+ GtkTreeViewColumn *column,
+ EphyNodeView *view)
{
- GtkTreeIter iter, iter2;
- EphyNode *node;
+ GtkTreeIter iter, iter2;
+ EphyNode *node;
- gtk_tree_model_get_iter (view->sortmodel, &iter, path);
- gtk_tree_model_sort_convert_iter_to_child_iter
- (GTK_TREE_MODEL_SORT (view->sortmodel), &iter2, &iter);
- gtk_tree_model_filter_convert_iter_to_child_iter
- (GTK_TREE_MODEL_FILTER (view->filtermodel), &iter, &iter2);
+ gtk_tree_model_get_iter (view->sortmodel, &iter, path);
+ gtk_tree_model_sort_convert_iter_to_child_iter
+ (GTK_TREE_MODEL_SORT (view->sortmodel), &iter2, &iter);
+ gtk_tree_model_filter_convert_iter_to_child_iter
+ (GTK_TREE_MODEL_FILTER (view->filtermodel), &iter, &iter2);
- node = ephy_tree_model_node_node_from_iter (view->nodemodel, &iter);
+ node = ephy_tree_model_node_node_from_iter (view->nodemodel, &iter);
- g_signal_emit (G_OBJECT (view), ephy_node_view_signals[NODE_ACTIVATED], 0, node);
+ g_signal_emit (G_OBJECT (view), ephy_node_view_signals[NODE_ACTIVATED], 0, node);
}
static void
path_toggled (GtkTreeModel *dummy_model, GtkTreePath *path,
- GtkTreeIter *dummy, gpointer data)
-{
- EphyNodeView *view = EPHY_NODE_VIEW (data);
- gboolean checked;
- EphyNode *node;
- GtkTreeIter iter, iter2;
- GValue value = {0, };
-
- gtk_tree_model_get_iter (view->sortmodel, &iter, path);
- gtk_tree_model_sort_convert_iter_to_child_iter
- (GTK_TREE_MODEL_SORT (view->sortmodel), &iter2, &iter);
- gtk_tree_model_filter_convert_iter_to_child_iter
- (GTK_TREE_MODEL_FILTER (view->filtermodel), &iter, &iter2);
-
- node = ephy_tree_model_node_node_from_iter (view->nodemodel, &iter);
- gtk_tree_model_get_value (GTK_TREE_MODEL (view->nodemodel), &iter,
- view->toggle_column, &value);
- checked = !g_value_get_boolean (&value);
-
- g_signal_emit (G_OBJECT (view), ephy_node_view_signals[NODE_TOGGLED], 0,
- node, checked);
+ GtkTreeIter *dummy, gpointer data)
+{
+ EphyNodeView *view = EPHY_NODE_VIEW (data);
+ gboolean checked;
+ EphyNode *node;
+ GtkTreeIter iter, iter2;
+ GValue value = { 0, };
+
+ gtk_tree_model_get_iter (view->sortmodel, &iter, path);
+ gtk_tree_model_sort_convert_iter_to_child_iter
+ (GTK_TREE_MODEL_SORT (view->sortmodel), &iter2, &iter);
+ gtk_tree_model_filter_convert_iter_to_child_iter
+ (GTK_TREE_MODEL_FILTER (view->filtermodel), &iter, &iter2);
+
+ node = ephy_tree_model_node_node_from_iter (view->nodemodel, &iter);
+ gtk_tree_model_get_value (GTK_TREE_MODEL (view->nodemodel), &iter,
+ view->toggle_column, &value);
+ checked = !g_value_get_boolean (&value);
+
+ g_signal_emit (G_OBJECT (view), ephy_node_view_signals[NODE_TOGGLED], 0,
+ node, checked);
}
static EphyNode *
-process_middle_click (GtkTreePath *path,
- EphyNodeView *view)
+process_middle_click (GtkTreePath *path,
+ EphyNodeView *view)
{
- EphyNode *node;
- GtkTreeIter iter, iter2;
+ EphyNode *node;
+ GtkTreeIter iter, iter2;
- gtk_tree_model_get_iter (view->sortmodel, &iter, path);
- gtk_tree_model_sort_convert_iter_to_child_iter
- (GTK_TREE_MODEL_SORT (view->sortmodel), &iter2, &iter);
- gtk_tree_model_filter_convert_iter_to_child_iter
- (GTK_TREE_MODEL_FILTER (view->filtermodel), &iter, &iter2);
+ gtk_tree_model_get_iter (view->sortmodel, &iter, path);
+ gtk_tree_model_sort_convert_iter_to_child_iter
+ (GTK_TREE_MODEL_SORT (view->sortmodel), &iter2, &iter);
+ gtk_tree_model_filter_convert_iter_to_child_iter
+ (GTK_TREE_MODEL_FILTER (view->filtermodel), &iter, &iter2);
- node = ephy_tree_model_node_node_from_iter (view->nodemodel, &iter);
+ node = ephy_tree_model_node_node_from_iter (view->nodemodel, &iter);
- return node;
+ return node;
}
static gboolean
-ephy_node_view_key_press_cb (GtkTreeView *treeview,
- GdkEventKey *event,
- EphyNodeView *view)
-{
- gboolean handled = FALSE;
-
- if (event->keyval == GDK_KEY_space ||
- event->keyval == GDK_KEY_Return ||
- event->keyval == GDK_KEY_KP_Enter ||
- event->keyval == GDK_KEY_ISO_Enter)
- {
- if (view->toggle_column >= 0)
- {
- GtkTreeSelection *selection;
-
- selection = gtk_tree_view_get_selection (treeview);
- gtk_tree_selection_selected_foreach (selection, path_toggled, view);
- handled = TRUE;
- }
- }
-
- return handled;
+ephy_node_view_key_press_cb (GtkTreeView *treeview,
+ GdkEventKey *event,
+ EphyNodeView *view)
+{
+ gboolean handled = FALSE;
+
+ if (event->keyval == GDK_KEY_space ||
+ event->keyval == GDK_KEY_Return ||
+ event->keyval == GDK_KEY_KP_Enter ||
+ event->keyval == GDK_KEY_ISO_Enter) {
+ if (view->toggle_column >= 0) {
+ GtkTreeSelection *selection;
+
+ selection = gtk_tree_view_get_selection (treeview);
+ gtk_tree_selection_selected_foreach (selection, path_toggled, view);
+ handled = TRUE;
+ }
+ }
+
+ return handled;
}
static void
selection_foreach (GtkTreeModel *model,
- GtkTreePath *path,
- GtkTreeIter *iter,
- gpointer data)
+ GtkTreePath *path,
+ GtkTreeIter *iter,
+ gpointer data)
{
- GList **list;
+ GList **list;
- list = (GList**)data;
+ list = (GList **)data;
- *list = g_list_prepend (*list, gtk_tree_row_reference_new (model, path));
+ *list = g_list_prepend (*list, gtk_tree_row_reference_new (model, path));
}
static GList *
get_selection_refs (GtkTreeView *tree_view)
{
- GtkTreeSelection *selection;
- GList *ref_list = NULL;
-
- selection = gtk_tree_view_get_selection (tree_view);
- gtk_tree_selection_selected_foreach (selection,
- selection_foreach,
- &ref_list);
- ref_list = g_list_reverse (ref_list);
- return ref_list;
+ GtkTreeSelection *selection;
+ GList *ref_list = NULL;
+
+ selection = gtk_tree_view_get_selection (tree_view);
+ gtk_tree_selection_selected_foreach (selection,
+ selection_foreach,
+ &ref_list);
+ ref_list = g_list_reverse (ref_list);
+ return ref_list;
}
static void
ref_list_free (GList *ref_list)
{
- g_list_foreach (ref_list, (GFunc) gtk_tree_row_reference_free, NULL);
- g_list_free (ref_list);
+ g_list_foreach (ref_list, (GFunc)gtk_tree_row_reference_free, NULL);
+ g_list_free (ref_list);
}
static void
stop_drag_check (EphyNodeView *view)
{
- view->drag_button = 0;
+ view->drag_button = 0;
}
static gboolean
button_event_modifies_selection (GdkEventButton *event)
{
- return (event->state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK)) != 0;
+ return (event->state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK)) != 0;
}
static void
-did_not_drag (EphyNodeView *view,
- GdkEventButton *event)
-{
- GtkTreeView *tree_view;
- GtkTreeSelection *selection;
- GtkTreePath *path;
-
- tree_view = GTK_TREE_VIEW (view);
- selection = gtk_tree_view_get_selection (tree_view);
-
- if (gtk_tree_view_get_path_at_pos (tree_view, event->x, event->y,
- &path, NULL, NULL, NULL))
- {
- if((event->button == 1 || event->button == 2) &&
- gtk_tree_selection_path_is_selected (selection, path) &&
- !button_event_modifies_selection (event))
- {
- if (gtk_tree_selection_get_mode (selection) == GTK_SELECTION_MULTIPLE)
- {
- gtk_tree_selection_unselect_all (selection);
- }
-
- gtk_tree_selection_select_path (selection, path);
- }
-
- gtk_tree_path_free (path);
- }
+did_not_drag (EphyNodeView *view,
+ GdkEventButton *event)
+{
+ GtkTreeView *tree_view;
+ GtkTreeSelection *selection;
+ GtkTreePath *path;
+
+ tree_view = GTK_TREE_VIEW (view);
+ selection = gtk_tree_view_get_selection (tree_view);
+
+ if (gtk_tree_view_get_path_at_pos (tree_view, event->x, event->y,
+ &path, NULL, NULL, NULL)) {
+ if ((event->button == 1 || event->button == 2) &&
+ gtk_tree_selection_path_is_selected (selection, path) &&
+ !button_event_modifies_selection (event)) {
+ if (gtk_tree_selection_get_mode (selection) == GTK_SELECTION_MULTIPLE) {
+ gtk_tree_selection_unselect_all (selection);
+ }
+
+ gtk_tree_selection_select_path (selection, path);
+ }
+
+ gtk_tree_path_free (path);
+ }
}
-typedef struct
-{
- EphyNodeView *view;
- gboolean result;
+typedef struct {
+ EphyNodeView *view;
+ gboolean result;
}
ForeachData;
static void
check_node_is_drag_source (GtkTreeModel *model,
- GtkTreePath *path,
- GtkTreeIter *iter,
- ForeachData *data)
+ GtkTreePath *path,
+ GtkTreeIter *iter,
+ ForeachData *data)
{
- EphyNode *node;
+ EphyNode *node;
- node = get_node_from_path (data->view, path);
- data->result = data->result &&
- node != NULL &&
- ephy_node_get_is_drag_source (node);
+ node = get_node_from_path (data->view, path);
+ data->result = data->result &&
+ node != NULL &&
+ ephy_node_get_is_drag_source (node);
}
static gboolean
can_drag_selection (EphyNodeView *view)
{
- GtkTreeView *tree_view = GTK_TREE_VIEW (view);
- GtkTreeSelection *selection;
- ForeachData data = { view, TRUE };
+ GtkTreeView *tree_view = GTK_TREE_VIEW (view);
+ GtkTreeSelection *selection;
+ ForeachData data = { view, TRUE };
- selection = gtk_tree_view_get_selection (tree_view);
- gtk_tree_selection_selected_foreach (selection,
- (GtkTreeSelectionForeachFunc) check_node_is_drag_source,
- &data);
+ selection = gtk_tree_view_get_selection (tree_view);
+ gtk_tree_selection_selected_foreach (selection,
+ (GtkTreeSelectionForeachFunc)check_node_is_drag_source,
+ &data);
- return data.result;
+ return data.result;
}
static void
-drag_data_get_cb (GtkWidget *widget,
- GdkDragContext *context,
- GtkSelectionData *selection_data,
- guint info,
- guint time)
+drag_data_get_cb (GtkWidget *widget,
+ GdkDragContext *context,
+ GtkSelectionData *selection_data,
+ guint info,
+ guint time)
{
- GtkTreeView *tree_view;
- GtkTreeModel *model;
- GList *ref_list;
+ GtkTreeView *tree_view;
+ GtkTreeModel *model;
+ GList *ref_list;
- tree_view = GTK_TREE_VIEW (widget);
+ tree_view = GTK_TREE_VIEW (widget);
- model = gtk_tree_view_get_model (tree_view);
- g_return_if_fail (model != NULL);
+ model = gtk_tree_view_get_model (tree_view);
+ g_return_if_fail (model != NULL);
- ref_list = g_object_get_data (G_OBJECT (context), "drag-info");
+ ref_list = g_object_get_data (G_OBJECT (context), "drag-info");
- if (ref_list == NULL)
- {
- return;
- }
+ if (ref_list == NULL) {
+ return;
+ }
- if (EGG_IS_TREE_MULTI_DRAG_SOURCE (model))
- {
- egg_tree_multi_drag_source_drag_data_get (EGG_TREE_MULTI_DRAG_SOURCE (model),
- ref_list,
- selection_data);
- }
+ if (EGG_IS_TREE_MULTI_DRAG_SOURCE (model)) {
+ egg_tree_multi_drag_source_drag_data_get (EGG_TREE_MULTI_DRAG_SOURCE (model),
+ ref_list,
+ selection_data);
+ }
}
static gboolean
-button_release_cb (GtkWidget *widget,
- GdkEventButton *event,
- EphyNodeView *view)
-{
- if ((int)event->button == view->drag_button)
- {
- stop_drag_check (view);
- if (!view->drag_started)
- {
- did_not_drag (view, event);
- return TRUE;
- }
- view->drag_started = FALSE;
- }
- return FALSE;
+button_release_cb (GtkWidget *widget,
+ GdkEventButton *event,
+ EphyNodeView *view)
+{
+ if ((int)event->button == view->drag_button) {
+ stop_drag_check (view);
+ if (!view->drag_started) {
+ did_not_drag (view, event);
+ return TRUE;
+ }
+ view->drag_started = FALSE;
+ }
+ return FALSE;
}
static gboolean
-motion_notify_cb (GtkWidget *widget,
- GdkEventMotion *event,
- EphyNodeView *view)
-{
- GdkDragContext *context;
- GList *ref_list;
-
- if (event->window != gtk_tree_view_get_bin_window (GTK_TREE_VIEW (widget)))
- {
- return FALSE;
- }
- if (view->drag_button != 0)
- {
- if (gtk_drag_check_threshold (widget, view->drag_x,
- view->drag_y, event->x,
- event->y)
- && can_drag_selection (view))
- {
- context = gtk_drag_begin
- (widget, view->source_target_list,
- GDK_ACTION_ASK | GDK_ACTION_COPY | GDK_ACTION_LINK,
- view->drag_button,
- (GdkEvent*)event);
-
- stop_drag_check (view);
- view->drag_started = TRUE;
-
- ref_list = get_selection_refs (GTK_TREE_VIEW (widget));
- g_object_set_data_full (G_OBJECT (context),
- "drag-info",
- ref_list,
- (GDestroyNotify)ref_list_free);
-
- gtk_drag_set_icon_default (context);
- }
- }
-
- return TRUE;
+motion_notify_cb (GtkWidget *widget,
+ GdkEventMotion *event,
+ EphyNodeView *view)
+{
+ GdkDragContext *context;
+ GList *ref_list;
+
+ if (event->window != gtk_tree_view_get_bin_window (GTK_TREE_VIEW (widget))) {
+ return FALSE;
+ }
+ if (view->drag_button != 0) {
+ if (gtk_drag_check_threshold (widget, view->drag_x,
+ view->drag_y, event->x,
+ event->y)
+ && can_drag_selection (view)) {
+ context = gtk_drag_begin
+ (widget, view->source_target_list,
+ GDK_ACTION_ASK | GDK_ACTION_COPY | GDK_ACTION_LINK,
+ view->drag_button,
+ (GdkEvent *)event);
+
+ stop_drag_check (view);
+ view->drag_started = TRUE;
+
+ ref_list = get_selection_refs (GTK_TREE_VIEW (widget));
+ g_object_set_data_full (G_OBJECT (context),
+ "drag-info",
+ ref_list,
+ (GDestroyNotify)ref_list_free);
+
+ gtk_drag_set_icon_default (context);
+ }
+ }
+
+ return TRUE;
}
static gboolean
-ephy_node_view_button_press_cb (GtkWidget *treeview,
- GdkEventButton *event,
- EphyNodeView *view)
-{
- GtkTreePath *path = NULL;
- GtkTreeSelection *selection;
- gboolean call_parent = TRUE, path_is_selected;
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview));
-
- if (event->window != gtk_tree_view_get_bin_window (GTK_TREE_VIEW (treeview)))
- {
- return GTK_WIDGET_CLASS (ephy_node_view_parent_class)->button_press_event (treeview, event);
- }
-
- if (gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (treeview),
- event->x,
- event->y,
- &path,
- NULL, NULL, NULL))
- {
- path_is_selected = gtk_tree_selection_path_is_selected (selection, path);
-
- if (!gtk_widget_is_focus (GTK_WIDGET (treeview)))
- {
- gtk_widget_grab_focus (GTK_WIDGET (treeview));
- }
-
- if (event->button == 3 && path_is_selected)
- {
- call_parent = FALSE;
- }
-
- if(!button_event_modifies_selection (event) &&
- event->button == 1 && path_is_selected &&
- gtk_tree_selection_count_selected_rows (selection) > 1)
- {
- call_parent = FALSE;
- }
-
- if (call_parent)
- {
- GTK_WIDGET_CLASS (ephy_node_view_parent_class)->button_press_event (treeview, event);
- }
-
- if (event->button == 3)
- {
- gboolean retval;
-
- g_signal_emit_by_name (view, "popup_menu", &retval);
- }
- else if (event->button == 2)
- {
- EphyNode *clicked_node;
-
- clicked_node = process_middle_click (path, view);
- g_signal_emit (G_OBJECT (view),
- ephy_node_view_signals[NODE_MIDDLE_CLICKED], 0, clicked_node);
- }
- else if (event->button == 1)
- {
- if (view->toggle_column >= 0)
- {
- path_toggled (NULL, path, NULL, view);
- }
- else
- {
- view->drag_started = FALSE;
- view->drag_button = event->button;
- view->drag_x = event->x;
- view->drag_y = event->y;
- }
- }
-
- gtk_tree_path_free (path);
- }
- else
- {
- gtk_tree_selection_unselect_all (selection);
- }
-
- return TRUE;
+ephy_node_view_button_press_cb (GtkWidget *treeview,
+ GdkEventButton *event,
+ EphyNodeView *view)
+{
+ GtkTreePath *path = NULL;
+ GtkTreeSelection *selection;
+ gboolean call_parent = TRUE, path_is_selected;
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview));
+
+ if (event->window != gtk_tree_view_get_bin_window (GTK_TREE_VIEW (treeview))) {
+ return GTK_WIDGET_CLASS (ephy_node_view_parent_class)->button_press_event (treeview, event);
+ }
+
+ if (gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (treeview),
+ event->x,
+ event->y,
+ &path,
+ NULL, NULL, NULL)) {
+ path_is_selected = gtk_tree_selection_path_is_selected (selection, path);
+
+ if (!gtk_widget_is_focus (GTK_WIDGET (treeview))) {
+ gtk_widget_grab_focus (GTK_WIDGET (treeview));
+ }
+
+ if (event->button == 3 && path_is_selected) {
+ call_parent = FALSE;
+ }
+
+ if (!button_event_modifies_selection (event) &&
+ event->button == 1 && path_is_selected &&
+ gtk_tree_selection_count_selected_rows (selection) > 1) {
+ call_parent = FALSE;
+ }
+
+ if (call_parent) {
+ GTK_WIDGET_CLASS (ephy_node_view_parent_class)->button_press_event (treeview, event);
+ }
+
+ if (event->button == 3) {
+ gboolean retval;
+
+ g_signal_emit_by_name (view, "popup_menu", &retval);
+ } else if (event->button == 2) {
+ EphyNode *clicked_node;
+
+ clicked_node = process_middle_click (path, view);
+ g_signal_emit (G_OBJECT (view),
+ ephy_node_view_signals[NODE_MIDDLE_CLICKED], 0, clicked_node);
+ } else if (event->button == 1) {
+ if (view->toggle_column >= 0) {
+ path_toggled (NULL, path, NULL, view);
+ } else {
+ view->drag_started = FALSE;
+ view->drag_button = event->button;
+ view->drag_x = event->x;
+ view->drag_y = event->y;
+ }
+ }
+
+ gtk_tree_path_free (path);
+ } else {
+ gtk_tree_selection_unselect_all (selection);
+ }
+
+ return TRUE;
}
static void
ephy_node_view_set_filter (EphyNodeView *view, EphyNodeFilter *filter)
{
- gboolean refilter = FALSE;
-
- if (view->filter)
- {
- g_object_unref (view->filter);
- refilter = TRUE;
- }
-
- if (filter)
- {
- view->filter = g_object_ref (filter);
- g_signal_connect_object (G_OBJECT (view->filter),
- "changed", G_CALLBACK (filter_changed_cb),
- G_OBJECT (view), 0);
- }
-
- if (refilter)
- {
- gtk_tree_model_filter_refilter
- (GTK_TREE_MODEL_FILTER (view->filtermodel));
- }
+ gboolean refilter = FALSE;
+
+ if (view->filter) {
+ g_object_unref (view->filter);
+ refilter = TRUE;
+ }
+
+ if (filter) {
+ view->filter = g_object_ref (filter);
+ g_signal_connect_object (G_OBJECT (view->filter),
+ "changed", G_CALLBACK (filter_changed_cb),
+ G_OBJECT (view), 0);
+ }
+
+ if (refilter) {
+ gtk_tree_model_filter_refilter
+ (GTK_TREE_MODEL_FILTER (view->filtermodel));
+ }
}
static void
-ephy_node_view_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- EphyNodeView *view = EPHY_NODE_VIEW (object);
-
- switch (prop_id)
- {
- case PROP_ROOT:
- view->root = g_value_get_pointer (value);
- break;
- case PROP_FILTER:
- ephy_node_view_set_filter (view, g_value_get_object (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ephy_node_view_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ EphyNodeView *view = EPHY_NODE_VIEW (object);
+
+ switch (prop_id) {
+ case PROP_ROOT:
+ view->root = g_value_get_pointer (value);
+ break;
+ case PROP_FILTER:
+ ephy_node_view_set_filter (view, g_value_get_object (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
-ephy_node_view_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- EphyNodeView *view = EPHY_NODE_VIEW (object);
-
- switch (prop_id)
- {
- case PROP_ROOT:
- g_value_set_pointer (value, view->root);
- break;
- case PROP_FILTER:
- g_value_set_object (value, view->filter);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ephy_node_view_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ EphyNodeView *view = EPHY_NODE_VIEW (object);
+
+ switch (prop_id) {
+ case PROP_ROOT:
+ g_value_set_pointer (value, view->root);
+ break;
+ case PROP_FILTER:
+ g_value_set_object (value, view->filter);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
/**
@@ -966,232 +903,201 @@ ephy_node_view_get_property (GObject *object,
* Returns: a new #EphyNodeView as a #GtkWidget
**/
GtkWidget *
-ephy_node_view_new (EphyNode *root,
- EphyNodeFilter *filter)
+ephy_node_view_new (EphyNode *root,
+ EphyNodeFilter *filter)
{
- EphyNodeView *view;
+ EphyNodeView *view;
- view = EPHY_NODE_VIEW (g_object_new (EPHY_TYPE_NODE_VIEW,
- "filter", filter,
- "root", root,
- NULL));
+ view = EPHY_NODE_VIEW (g_object_new (EPHY_TYPE_NODE_VIEW,
+ "filter", filter,
+ "root", root,
+ NULL));
- return GTK_WIDGET (view);
+ return GTK_WIDGET (view);
}
static void
cell_renderer_edited (GtkCellRendererText *cell,
- const char *path_str,
- const char *new_text,
- EphyNodeView *view)
+ const char *path_str,
+ const char *new_text,
+ EphyNodeView *view)
{
- GtkTreePath *path;
- GtkTreeIter iter, iter2;
- EphyNode *node;
+ GtkTreePath *path;
+ GtkTreeIter iter, iter2;
+ EphyNode *node;
- view->edited_node = NULL;
+ view->edited_node = NULL;
- g_object_set (G_OBJECT (view->editable_renderer),
- "editable", FALSE,
- NULL);
+ g_object_set (G_OBJECT (view->editable_renderer),
+ "editable", FALSE,
+ NULL);
- path = gtk_tree_path_new_from_string (path_str);
- gtk_tree_model_get_iter (view->sortmodel, &iter, path);
- gtk_tree_model_sort_convert_iter_to_child_iter
- (GTK_TREE_MODEL_SORT (view->sortmodel), &iter2, &iter);
- gtk_tree_model_filter_convert_iter_to_child_iter
- (GTK_TREE_MODEL_FILTER (view->filtermodel), &iter, &iter2);
- node = ephy_tree_model_node_node_from_iter (view->nodemodel, &iter);
+ path = gtk_tree_path_new_from_string (path_str);
+ gtk_tree_model_get_iter (view->sortmodel, &iter, path);
+ gtk_tree_model_sort_convert_iter_to_child_iter
+ (GTK_TREE_MODEL_SORT (view->sortmodel), &iter2, &iter);
+ gtk_tree_model_filter_convert_iter_to_child_iter
+ (GTK_TREE_MODEL_FILTER (view->filtermodel), &iter, &iter2);
+ node = ephy_tree_model_node_node_from_iter (view->nodemodel, &iter);
- ephy_node_set_property_string (node, view->editable_property,
- new_text);
+ ephy_node_set_property_string (node, view->editable_property,
+ new_text);
- gtk_tree_path_free (path);
+ gtk_tree_path_free (path);
- view->remove_if_cancelled = FALSE;
+ view->remove_if_cancelled = FALSE;
}
static void
renderer_editing_canceled_cb (GtkCellRendererText *cell,
- EphyNodeView *view)
+ EphyNodeView *view)
{
- if (view->remove_if_cancelled)
- {
- ephy_node_unref (view->edited_node);
- view->remove_if_cancelled = FALSE;
- }
+ if (view->remove_if_cancelled) {
+ ephy_node_unref (view->edited_node);
+ view->remove_if_cancelled = FALSE;
+ }
}
static inline int
compare_string_values (const GValue *a_value, const GValue *b_value)
{
- const char *str1, *str2;
- int retval;
-
- str1 = g_value_get_string (a_value);
- str2 = g_value_get_string (b_value);
-
- if (str1 == NULL)
- {
- retval = -1;
- }
- else if (str2 == NULL)
- {
- retval = 1;
- }
- else
- {
- char *str_a;
- char *str_b;
-
- str_a = g_utf8_casefold (str1, -1);
- str_b = g_utf8_casefold (str2, -1);
- retval = g_utf8_collate (str_a, str_b);
- g_free (str_a);
- g_free (str_b);
- }
-
- return retval;
+ const char *str1, *str2;
+ int retval;
+
+ str1 = g_value_get_string (a_value);
+ str2 = g_value_get_string (b_value);
+
+ if (str1 == NULL) {
+ retval = -1;
+ } else if (str2 == NULL) {
+ retval = 1;
+ } else {
+ char *str_a;
+ char *str_b;
+
+ str_a = g_utf8_casefold (str1, -1);
+ str_b = g_utf8_casefold (str2, -1);
+ retval = g_utf8_collate (str_a, str_b);
+ g_free (str_a);
+ g_free (str_b);
+ }
+
+ return retval;
}
static int
ephy_node_view_sort_func (GtkTreeModel *model,
- GtkTreeIter *a,
- GtkTreeIter *b,
- EphyNodeView *view)
-{
- GValue a_value = {0, };
- GValue b_value = {0, };
- int p_column, column, retval = 0;
- GtkSortType sort_type;
-
- g_return_val_if_fail (model != NULL, 0);
- g_return_val_if_fail (view != NULL, 0);
-
- p_column = view->priority_column;
- column = view->sort_column;
- sort_type = view->sort_type;
-
- if (p_column >= 0)
- {
- gtk_tree_model_get_value (model, a, p_column, &a_value);
- gtk_tree_model_get_value (model, b, p_column, &b_value);
-
- if (g_value_get_int (&a_value) < g_value_get_int (&b_value))
- {
- retval = -1;
- }
- else if (g_value_get_int (&a_value) == g_value_get_int (&b_value))
- {
- retval = 0;
- }
- else
- {
- retval = 1;
- }
-
- g_value_unset (&a_value);
- g_value_unset (&b_value);
- }
-
-
- if (retval == 0)
- {
- GType type;
-
- type = gtk_tree_model_get_column_type (model, column);
-
- gtk_tree_model_get_value (model, a, column, &a_value);
- gtk_tree_model_get_value (model, b, column, &b_value);
-
- switch (G_TYPE_FUNDAMENTAL (type))
- {
- case G_TYPE_STRING:
- retval = compare_string_values (&a_value, &b_value);
- break;
- case G_TYPE_INT:
- if (g_value_get_int (&a_value) < g_value_get_int (&b_value))
- {
- retval = -1;
- }
- else if (g_value_get_int (&a_value) == g_value_get_int (&b_value))
- {
- retval = 0;
- }
- else
- {
- retval = 1;
- }
- break;
- case G_TYPE_BOOLEAN:
- if (g_value_get_boolean (&a_value) < g_value_get_boolean (&b_value))
- {
- retval = -1;
- }
- else if (g_value_get_boolean (&a_value) == g_value_get_boolean (&b_value))
- {
- retval = 0;
- }
- else
- {
- retval = 1;
- }
- break;
- default:
- g_warning ("Attempting to sort on invalid type %s\n", g_type_name (type));
- break;
- }
-
- g_value_unset (&a_value);
- g_value_unset (&b_value);
- }
-
- if (sort_type == GTK_SORT_DESCENDING)
- {
- if (retval > 0)
- {
- retval = -1;
- }
- else if (retval < 0)
- {
- retval = 1;
- }
- }
-
- return retval;
+ GtkTreeIter *a,
+ GtkTreeIter *b,
+ EphyNodeView *view)
+{
+ GValue a_value = { 0, };
+ GValue b_value = { 0, };
+ int p_column, column, retval = 0;
+ GtkSortType sort_type;
+
+ g_return_val_if_fail (model != NULL, 0);
+ g_return_val_if_fail (view != NULL, 0);
+
+ p_column = view->priority_column;
+ column = view->sort_column;
+ sort_type = view->sort_type;
+
+ if (p_column >= 0) {
+ gtk_tree_model_get_value (model, a, p_column, &a_value);
+ gtk_tree_model_get_value (model, b, p_column, &b_value);
+
+ if (g_value_get_int (&a_value) < g_value_get_int (&b_value)) {
+ retval = -1;
+ } else if (g_value_get_int (&a_value) == g_value_get_int (&b_value)) {
+ retval = 0;
+ } else {
+ retval = 1;
+ }
+
+ g_value_unset (&a_value);
+ g_value_unset (&b_value);
+ }
+
+
+ if (retval == 0) {
+ GType type;
+
+ type = gtk_tree_model_get_column_type (model, column);
+
+ gtk_tree_model_get_value (model, a, column, &a_value);
+ gtk_tree_model_get_value (model, b, column, &b_value);
+
+ switch (G_TYPE_FUNDAMENTAL (type)) {
+ case G_TYPE_STRING:
+ retval = compare_string_values (&a_value, &b_value);
+ break;
+ case G_TYPE_INT:
+ if (g_value_get_int (&a_value) < g_value_get_int (&b_value)) {
+ retval = -1;
+ } else if (g_value_get_int (&a_value) == g_value_get_int (&b_value)) {
+ retval = 0;
+ } else {
+ retval = 1;
+ }
+ break;
+ case G_TYPE_BOOLEAN:
+ if (g_value_get_boolean (&a_value) < g_value_get_boolean (&b_value)) {
+ retval = -1;
+ } else if (g_value_get_boolean (&a_value) == g_value_get_boolean (&b_value)) {
+ retval = 0;
+ } else {
+ retval = 1;
+ }
+ break;
+ default:
+ g_warning ("Attempting to sort on invalid type %s\n", g_type_name (type));
+ break;
+ }
+
+ g_value_unset (&a_value);
+ g_value_unset (&b_value);
+ }
+
+ if (sort_type == GTK_SORT_DESCENDING) {
+ if (retval > 0) {
+ retval = -1;
+ } else if (retval < 0) {
+ retval = 1;
+ }
+ }
+
+ return retval;
}
static void
provide_priority (EphyNode *node, GValue *value, EphyNodeView *view)
{
- int priority;
-
- g_value_init (value, G_TYPE_INT);
- priority = ephy_node_get_property_int (node, view->priority_prop_id);
- if (priority == EPHY_NODE_VIEW_ALL_PRIORITY ||
- priority == EPHY_NODE_VIEW_SPECIAL_PRIORITY)
- g_value_set_int (value, priority);
- else
- g_value_set_int (value, EPHY_NODE_VIEW_NORMAL_PRIORITY);
+ int priority;
+
+ g_value_init (value, G_TYPE_INT);
+ priority = ephy_node_get_property_int (node, view->priority_prop_id);
+ if (priority == EPHY_NODE_VIEW_ALL_PRIORITY ||
+ priority == EPHY_NODE_VIEW_SPECIAL_PRIORITY)
+ g_value_set_int (value, priority);
+ else
+ g_value_set_int (value, EPHY_NODE_VIEW_NORMAL_PRIORITY);
}
static void
provide_text_weight (EphyNode *node, GValue *value, EphyNodeView *view)
{
- int priority;
-
- g_value_init (value, G_TYPE_INT);
- priority = ephy_node_get_property_int
- (node, view->priority_prop_id);
- if (priority == EPHY_NODE_VIEW_ALL_PRIORITY ||
- priority == EPHY_NODE_VIEW_SPECIAL_PRIORITY)
- {
- g_value_set_int (value, PANGO_WEIGHT_BOLD);
- }
- else
- {
- g_value_set_int (value, PANGO_WEIGHT_NORMAL);
- }
+ int priority;
+
+ g_value_init (value, G_TYPE_INT);
+ priority = ephy_node_get_property_int
+ (node, view->priority_prop_id);
+ if (priority == EPHY_NODE_VIEW_ALL_PRIORITY ||
+ priority == EPHY_NODE_VIEW_SPECIAL_PRIORITY) {
+ g_value_set_int (value, PANGO_WEIGHT_BOLD);
+ } else {
+ g_value_set_int (value, PANGO_WEIGHT_NORMAL);
+ }
}
/**
@@ -1208,26 +1114,23 @@ provide_text_weight (EphyNode *node, GValue *value, EphyNodeView *view)
* Returns: the id of the new column
**/
int
-ephy_node_view_add_data_column (EphyNodeView *view,
- GType value_type,
- guint prop_id,
- EphyTreeModelNodeValueFunc func,
- gpointer data)
-{
- int column;
-
- if (func)
- {
- column = ephy_tree_model_node_add_func_column
- (view->nodemodel, value_type, func, data);
- }
- else
- {
- column = ephy_tree_model_node_add_prop_column
- (view->nodemodel, value_type, prop_id);
- }
-
- return column;
+ephy_node_view_add_data_column (EphyNodeView *view,
+ GType value_type,
+ guint prop_id,
+ EphyTreeModelNodeValueFunc func,
+ gpointer data)
+{
+ int column;
+
+ if (func) {
+ column = ephy_tree_model_node_add_func_column
+ (view->nodemodel, value_type, func, data);
+ } else {
+ column = ephy_tree_model_node_add_prop_column
+ (view->nodemodel, value_type, prop_id);
+ }
+
+ return column;
}
/**
@@ -1247,103 +1150,97 @@ ephy_node_view_add_data_column (EphyNodeView *view,
* Returns: the id of the new column
**/
int
-ephy_node_view_add_column_full (EphyNodeView *view,
- const char *title,
- GType value_type,
- guint prop_id,
- EphyNodeViewFlags flags,
- EphyTreeModelNodeValueFunc func,
- gpointer user_data,
- EphyTreeModelNodeValueFunc icon_func,
- GtkTreeViewColumn **ret)
-{
- GtkTreeViewColumn *gcolumn;
- GtkCellRenderer *renderer;
- int column;
- int icon_column;
-
- column = ephy_tree_model_node_add_column_full
- (view->nodemodel, value_type, prop_id, func, user_data);
-
- gcolumn = (GtkTreeViewColumn *) gtk_tree_view_column_new ();
-
- if (icon_func)
- {
- icon_column = ephy_tree_model_node_add_func_column
- (view->nodemodel, GDK_TYPE_PIXBUF, icon_func, view);
-
- renderer = gtk_cell_renderer_pixbuf_new ();
- gtk_tree_view_column_pack_start (gcolumn, renderer, FALSE);
- gtk_tree_view_column_set_attributes (gcolumn, renderer,
- "pixbuf", icon_column,
- NULL);
- }
-
- renderer = gtk_cell_renderer_text_new ();
-
- if (flags & EPHY_NODE_VIEW_EDITABLE)
- {
- view->editable_renderer = renderer;
- view->editable_column = gcolumn;
- view->editable_node_column = column;
- view->editable_property = prop_id;
-
- g_signal_connect (renderer, "edited",
- G_CALLBACK (cell_renderer_edited), view);
- g_signal_connect (renderer, "editing-canceled",
- G_CALLBACK (renderer_editing_canceled_cb), view);
- }
-
- gtk_tree_view_column_pack_start (gcolumn, renderer, TRUE);
- gtk_tree_view_column_set_attributes (gcolumn, renderer,
- "text", column,
- NULL);
-
- gtk_tree_view_column_set_title (gcolumn, title);
- gtk_tree_view_append_column (GTK_TREE_VIEW (view),
- gcolumn);
-
- if (flags & EPHY_NODE_VIEW_SHOW_PRIORITY)
- {
- int wcol;
-
- wcol = ephy_tree_model_node_add_func_column
- (view->nodemodel, G_TYPE_INT,
- (EphyTreeModelNodeValueFunc) provide_text_weight,
- view);
- gtk_tree_view_column_add_attribute (gcolumn, renderer,
- "weight", wcol);
- }
-
- if (flags & EPHY_NODE_VIEW_SORTABLE)
- {
- /* Now we have created a new column, re-create the
- * sort model, but ensure that the set_sort function
- * hasn't been called, see bug #320686 */
- g_assert (view->sort_column == -1);
- g_object_unref (view->sortmodel);
- view->sortmodel = ephy_tree_model_sort_new (view->filtermodel);
- gtk_tree_view_set_model (GTK_TREE_VIEW (view), GTK_TREE_MODEL (view->sortmodel));
-
- gtk_tree_view_column_set_sort_column_id (gcolumn, column);
- }
-
- if (flags & EPHY_NODE_VIEW_SEARCHABLE)
- {
- gtk_tree_view_set_search_column (GTK_TREE_VIEW (view), column);
- gtk_tree_view_set_enable_search (GTK_TREE_VIEW (view), TRUE);
- }
-
- if (flags & EPHY_NODE_VIEW_ELLIPSIZED)
- {
- g_object_set (renderer, "ellipsize-set", TRUE,
- "ellipsize", PANGO_ELLIPSIZE_END, NULL);
- }
-
- if (ret != NULL)
- *ret = gcolumn;
-
- return column;
+ephy_node_view_add_column_full (EphyNodeView *view,
+ const char *title,
+ GType value_type,
+ guint prop_id,
+ EphyNodeViewFlags flags,
+ EphyTreeModelNodeValueFunc func,
+ gpointer user_data,
+ EphyTreeModelNodeValueFunc icon_func,
+ GtkTreeViewColumn **ret)
+{
+ GtkTreeViewColumn *gcolumn;
+ GtkCellRenderer *renderer;
+ int column;
+ int icon_column;
+
+ column = ephy_tree_model_node_add_column_full
+ (view->nodemodel, value_type, prop_id, func, user_data);
+
+ gcolumn = (GtkTreeViewColumn *)gtk_tree_view_column_new ();
+
+ if (icon_func) {
+ icon_column = ephy_tree_model_node_add_func_column
+ (view->nodemodel, GDK_TYPE_PIXBUF, icon_func, view);
+
+ renderer = gtk_cell_renderer_pixbuf_new ();
+ gtk_tree_view_column_pack_start (gcolumn, renderer, FALSE);
+ gtk_tree_view_column_set_attributes (gcolumn, renderer,
+ "pixbuf", icon_column,
+ NULL);
+ }
+
+ renderer = gtk_cell_renderer_text_new ();
+
+ if (flags & EPHY_NODE_VIEW_EDITABLE) {
+ view->editable_renderer = renderer;
+ view->editable_column = gcolumn;
+ view->editable_node_column = column;
+ view->editable_property = prop_id;
+
+ g_signal_connect (renderer, "edited",
+ G_CALLBACK (cell_renderer_edited), view);
+ g_signal_connect (renderer, "editing-canceled",
+ G_CALLBACK (renderer_editing_canceled_cb), view);
+ }
+
+ gtk_tree_view_column_pack_start (gcolumn, renderer, TRUE);
+ gtk_tree_view_column_set_attributes (gcolumn, renderer,
+ "text", column,
+ NULL);
+
+ gtk_tree_view_column_set_title (gcolumn, title);
+ gtk_tree_view_append_column (GTK_TREE_VIEW (view),
+ gcolumn);
+
+ if (flags & EPHY_NODE_VIEW_SHOW_PRIORITY) {
+ int wcol;
+
+ wcol = ephy_tree_model_node_add_func_column
+ (view->nodemodel, G_TYPE_INT,
+ (EphyTreeModelNodeValueFunc)provide_text_weight,
+ view);
+ gtk_tree_view_column_add_attribute (gcolumn, renderer,
+ "weight", wcol);
+ }
+
+ if (flags & EPHY_NODE_VIEW_SORTABLE) {
+ /* Now we have created a new column, re-create the
+ * sort model, but ensure that the set_sort function
+ * hasn't been called, see bug #320686 */
+ g_assert (view->sort_column == -1);
+ g_object_unref (view->sortmodel);
+ view->sortmodel = ephy_tree_model_sort_new (view->filtermodel);
+ gtk_tree_view_set_model (GTK_TREE_VIEW (view), GTK_TREE_MODEL (view->sortmodel));
+
+ gtk_tree_view_column_set_sort_column_id (gcolumn, column);
+ }
+
+ if (flags & EPHY_NODE_VIEW_SEARCHABLE) {
+ gtk_tree_view_set_search_column (GTK_TREE_VIEW (view), column);
+ gtk_tree_view_set_enable_search (GTK_TREE_VIEW (view), TRUE);
+ }
+
+ if (flags & EPHY_NODE_VIEW_ELLIPSIZED) {
+ g_object_set (renderer, "ellipsize-set", TRUE,
+ "ellipsize", PANGO_ELLIPSIZE_END, NULL);
+ }
+
+ if (ret != NULL)
+ *ret = gcolumn;
+
+ return column;
}
/**
@@ -1361,16 +1258,16 @@ ephy_node_view_add_column_full (EphyNodeView *view,
* Returns: the id of the new column
**/
int
-ephy_node_view_add_column (EphyNodeView *view,
- const char *title,
- GType value_type,
- guint prop_id,
- EphyNodeViewFlags flags,
- EphyTreeModelNodeValueFunc icon_func,
- GtkTreeViewColumn **ret)
-{
- return ephy_node_view_add_column_full (view, title, value_type, prop_id,
- flags, NULL, NULL, icon_func, ret);
+ephy_node_view_add_column (EphyNodeView *view,
+ const char *title,
+ GType value_type,
+ guint prop_id,
+ EphyNodeViewFlags flags,
+ EphyTreeModelNodeValueFunc icon_func,
+ GtkTreeViewColumn **ret)
+{
+ return ephy_node_view_add_column_full (view, title, value_type, prop_id,
+ flags, NULL, NULL, icon_func, ret);
}
/**
@@ -1383,15 +1280,15 @@ ephy_node_view_add_column (EphyNodeView *view,
void
ephy_node_view_set_priority (EphyNodeView *view, EphyNodeViewPriority priority_prop_id)
{
- int priority_column;
+ int priority_column;
- priority_column = ephy_tree_model_node_add_func_column
- (view->nodemodel, G_TYPE_INT,
- (EphyTreeModelNodeValueFunc) provide_priority,
- view);
+ priority_column = ephy_tree_model_node_add_func_column
+ (view->nodemodel, G_TYPE_INT,
+ (EphyTreeModelNodeValueFunc)provide_priority,
+ view);
- view->priority_column = priority_column;
- view->priority_prop_id = priority_prop_id;
+ view->priority_column = priority_column;
+ view->priority_prop_id = priority_prop_id;
}
/**
@@ -1405,49 +1302,49 @@ ephy_node_view_set_priority (EphyNodeView *view, EphyNodeViewPriority priority_p
**/
void
ephy_node_view_set_sort (EphyNodeView *view, GType value_type, guint prop_id,
- GtkSortType sort_type)
-{
- GtkTreeSortable *sortable = GTK_TREE_SORTABLE (view->sortmodel);
- int column;
-
- column = ephy_tree_model_node_add_prop_column
- (view->nodemodel, value_type, prop_id);
- view->sort_column = column;
- view->sort_type = sort_type;
-
- gtk_tree_sortable_set_default_sort_func
- (sortable, (GtkTreeIterCompareFunc)ephy_node_view_sort_func,
- view, NULL);
- gtk_tree_sortable_set_sort_column_id
- (sortable, GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID,
- sort_type);
+ GtkSortType sort_type)
+{
+ GtkTreeSortable *sortable = GTK_TREE_SORTABLE (view->sortmodel);
+ int column;
+
+ column = ephy_tree_model_node_add_prop_column
+ (view->nodemodel, value_type, prop_id);
+ view->sort_column = column;
+ view->sort_type = sort_type;
+
+ gtk_tree_sortable_set_default_sort_func
+ (sortable, (GtkTreeIterCompareFunc)ephy_node_view_sort_func,
+ view, NULL);
+ gtk_tree_sortable_set_sort_column_id
+ (sortable, GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID,
+ sort_type);
}
static void
ephy_node_view_init (EphyNodeView *view)
{
- view->toggle_column = -1;
- view->priority_column = -1;
- view->priority_prop_id = 0;
- view->sort_column = -1;
- view->sort_type = GTK_SORT_ASCENDING;
+ view->toggle_column = -1;
+ view->priority_column = -1;
+ view->priority_prop_id = 0;
+ view->sort_column = -1;
+ view->sort_type = GTK_SORT_ASCENDING;
- gtk_tree_view_set_enable_search (GTK_TREE_VIEW (view), FALSE);
+ gtk_tree_view_set_enable_search (GTK_TREE_VIEW (view), FALSE);
}
static void
get_selection (GtkTreeModel *model,
- GtkTreePath *path,
- GtkTreeIter *iter,
- gpointer *data)
+ GtkTreePath *path,
+ GtkTreeIter *iter,
+ gpointer *data)
{
- GList **list = data[0];
- EphyNodeView *view = EPHY_NODE_VIEW (data[1]);
- EphyNode *node;
+ GList **list = data[0];
+ EphyNodeView *view = EPHY_NODE_VIEW (data[1]);
+ EphyNode *node;
- node = get_node_from_path (view, path);
+ node = get_node_from_path (view, path);
- *list = g_list_prepend (*list, node);
+ *list = g_list_prepend (*list, node);
}
/**
@@ -1461,20 +1358,20 @@ get_selection (GtkTreeModel *model,
GList *
ephy_node_view_get_selection (EphyNodeView *view)
{
- GList *list = NULL;
- GtkTreeSelection *selection;
- gpointer data[2];
+ GList *list = NULL;
+ GtkTreeSelection *selection;
+ gpointer data[2];
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (view));
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (view));
- data[0] = &list;
- data[1] = view;
- gtk_tree_selection_selected_foreach
- (selection,
- (GtkTreeSelectionForeachFunc) get_selection,
- (gpointer) data);
+ data[0] = &list;
+ data[1] = view;
+ gtk_tree_selection_selected_foreach
+ (selection,
+ (GtkTreeSelectionForeachFunc)get_selection,
+ (gpointer)data);
- return list;
+ return list;
}
/**
@@ -1486,73 +1383,66 @@ ephy_node_view_get_selection (EphyNodeView *view)
void
ephy_node_view_remove (EphyNodeView *view)
{
- GList *list, *l;
- EphyNode *node;
- GtkTreeIter iter, iter2, iter3;
- GtkTreePath *path;
- GtkTreeRowReference *row_ref = NULL;
- GtkTreeSelection *selection;
-
- /* Before removing we try to get a reference to the next node in the view. If that is
- * not available we try with the previous one, and if that is absent too,
- * we will not select anything (which equals to select the topic "All")
- */
-
- list = ephy_node_view_get_selection (view);
- if (list == NULL) return;
-
- node = g_list_first (list)->data;
- ephy_tree_model_node_iter_from_node (EPHY_TREE_MODEL_NODE (view->nodemodel),
- node, &iter3);
- gtk_tree_model_filter_convert_child_iter_to_iter (GTK_TREE_MODEL_FILTER (view->filtermodel),
- &iter2, &iter3);
- gtk_tree_model_sort_convert_child_iter_to_iter (GTK_TREE_MODEL_SORT (view->sortmodel),
- &iter, &iter2);
- iter2 = iter;
-
- if (gtk_tree_model_iter_next (GTK_TREE_MODEL (view->sortmodel), &iter))
- {
- path = gtk_tree_model_get_path (GTK_TREE_MODEL (view->sortmodel), &iter);
- row_ref = gtk_tree_row_reference_new (GTK_TREE_MODEL (view->sortmodel), path);
- }
- else
- {
- path = gtk_tree_model_get_path (GTK_TREE_MODEL (view->sortmodel), &iter2);
- if (gtk_tree_path_prev (path))
- {
- row_ref = gtk_tree_row_reference_new (GTK_TREE_MODEL (view->sortmodel), path);
- }
- }
- gtk_tree_path_free (path);
-
- /* Work around bug #346662 */
- view->changing_selection = TRUE;
- for (l = list; l != NULL; l = l->next)
- {
- ephy_node_unref (l->data);
- }
- view->changing_selection = FALSE;
-
- g_list_free (list);
-
- /* Fake a selection changed signal */
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (view));
- g_signal_emit_by_name (selection, "changed");
-
- /* Select the "next" node */
-
- if (row_ref != NULL)
- {
- path = gtk_tree_row_reference_get_path (row_ref);
-
- if (path != NULL)
- {
- gtk_tree_view_set_cursor (GTK_TREE_VIEW (view), path, NULL, FALSE);
- gtk_tree_path_free (path);
- }
-
- gtk_tree_row_reference_free (row_ref);
- }
+ GList *list, *l;
+ EphyNode *node;
+ GtkTreeIter iter, iter2, iter3;
+ GtkTreePath *path;
+ GtkTreeRowReference *row_ref = NULL;
+ GtkTreeSelection *selection;
+
+ /* Before removing we try to get a reference to the next node in the view. If that is
+ * not available we try with the previous one, and if that is absent too,
+ * we will not select anything (which equals to select the topic "All")
+ */
+
+ list = ephy_node_view_get_selection (view);
+ if (list == NULL) return;
+
+ node = g_list_first (list)->data;
+ ephy_tree_model_node_iter_from_node (EPHY_TREE_MODEL_NODE (view->nodemodel),
+ node, &iter3);
+ gtk_tree_model_filter_convert_child_iter_to_iter (GTK_TREE_MODEL_FILTER (view->filtermodel),
+ &iter2, &iter3);
+ gtk_tree_model_sort_convert_child_iter_to_iter (GTK_TREE_MODEL_SORT (view->sortmodel),
+ &iter, &iter2);
+ iter2 = iter;
+
+ if (gtk_tree_model_iter_next (GTK_TREE_MODEL (view->sortmodel), &iter)) {
+ path = gtk_tree_model_get_path (GTK_TREE_MODEL (view->sortmodel), &iter);
+ row_ref = gtk_tree_row_reference_new (GTK_TREE_MODEL (view->sortmodel), path);
+ } else {
+ path = gtk_tree_model_get_path (GTK_TREE_MODEL (view->sortmodel), &iter2);
+ if (gtk_tree_path_prev (path)) {
+ row_ref = gtk_tree_row_reference_new (GTK_TREE_MODEL (view->sortmodel), path);
+ }
+ }
+ gtk_tree_path_free (path);
+
+ /* Work around bug #346662 */
+ view->changing_selection = TRUE;
+ for (l = list; l != NULL; l = l->next) {
+ ephy_node_unref (l->data);
+ }
+ view->changing_selection = FALSE;
+
+ g_list_free (list);
+
+ /* Fake a selection changed signal */
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (view));
+ g_signal_emit_by_name (selection, "changed");
+
+ /* Select the "next" node */
+
+ if (row_ref != NULL) {
+ path = gtk_tree_row_reference_get_path (row_ref);
+
+ if (path != NULL) {
+ gtk_tree_view_set_cursor (GTK_TREE_VIEW (view), path, NULL, FALSE);
+ gtk_tree_path_free (path);
+ }
+
+ gtk_tree_row_reference_free (row_ref);
+ }
}
/**
@@ -1564,21 +1454,21 @@ ephy_node_view_remove (EphyNodeView *view)
**/
void
ephy_node_view_select_node (EphyNodeView *view,
- EphyNode *node)
+ EphyNode *node)
{
- GtkTreeIter iter, iter2;
+ GtkTreeIter iter, iter2;
- g_return_if_fail (node != NULL);
+ g_return_if_fail (node != NULL);
- ephy_tree_model_node_iter_from_node (EPHY_TREE_MODEL_NODE (view->nodemodel),
- node, &iter);
- gtk_tree_model_filter_convert_child_iter_to_iter (GTK_TREE_MODEL_FILTER (view->filtermodel),
- &iter2, &iter);
- gtk_tree_model_sort_convert_child_iter_to_iter (GTK_TREE_MODEL_SORT (view->sortmodel),
- &iter, &iter2);
+ ephy_tree_model_node_iter_from_node (EPHY_TREE_MODEL_NODE (view->nodemodel),
+ node, &iter);
+ gtk_tree_model_filter_convert_child_iter_to_iter (GTK_TREE_MODEL_FILTER (view->filtermodel),
+ &iter2, &iter);
+ gtk_tree_model_sort_convert_child_iter_to_iter (GTK_TREE_MODEL_SORT (view->sortmodel),
+ &iter, &iter2);
- gtk_tree_selection_select_iter (gtk_tree_view_get_selection (GTK_TREE_VIEW (view)),
- &iter);
+ gtk_tree_selection_select_iter (gtk_tree_view_get_selection (GTK_TREE_VIEW (view)),
+ &iter);
}
/**
@@ -1592,37 +1482,37 @@ ephy_node_view_select_node (EphyNodeView *view,
* Sets @view as a drag source.
**/
void
-ephy_node_view_enable_drag_source (EphyNodeView *view,
- const GtkTargetEntry *types,
- int n_types,
- int base_drag_column_id,
- int extra_drag_column_id)
-{
- g_return_if_fail (view != NULL);
-
- view->source_target_list =
- gtk_target_list_new (types, n_types);
-
- ephy_tree_model_sort_set_base_drag_column_id (EPHY_TREE_MODEL_SORT (view->sortmodel),
- base_drag_column_id);
- ephy_tree_model_sort_set_extra_drag_column_id (EPHY_TREE_MODEL_SORT (view->sortmodel),
- extra_drag_column_id);
-
- g_signal_connect_object (G_OBJECT (view),
- "button_release_event",
- G_CALLBACK (button_release_cb),
- view,
- 0);
- g_signal_connect_object (G_OBJECT (view),
- "motion_notify_event",
- G_CALLBACK (motion_notify_cb),
- view,
- 0);
- g_signal_connect_object (G_OBJECT (view),
- "drag_data_get",
- G_CALLBACK (drag_data_get_cb),
- view,
- 0);
+ephy_node_view_enable_drag_source (EphyNodeView *view,
+ const GtkTargetEntry *types,
+ int n_types,
+ int base_drag_column_id,
+ int extra_drag_column_id)
+{
+ g_return_if_fail (view != NULL);
+
+ view->source_target_list =
+ gtk_target_list_new (types, n_types);
+
+ ephy_tree_model_sort_set_base_drag_column_id (EPHY_TREE_MODEL_SORT (view->sortmodel),
+ base_drag_column_id);
+ ephy_tree_model_sort_set_extra_drag_column_id (EPHY_TREE_MODEL_SORT (view->sortmodel),
+ extra_drag_column_id);
+
+ g_signal_connect_object (G_OBJECT (view),
+ "button_release_event",
+ G_CALLBACK (button_release_cb),
+ view,
+ 0);
+ g_signal_connect_object (G_OBJECT (view),
+ "motion_notify_event",
+ G_CALLBACK (motion_notify_cb),
+ view,
+ 0);
+ g_signal_connect_object (G_OBJECT (view),
+ "drag_data_get",
+ G_CALLBACK (drag_data_get_cb),
+ view,
+ 0);
}
/**
@@ -1636,33 +1526,33 @@ ephy_node_view_enable_drag_source (EphyNodeView *view,
void
ephy_node_view_edit (EphyNodeView *view, gboolean remove_if_cancelled)
{
- GtkTreePath *path;
- GtkTreeSelection *selection;
- GList *rows;
- GtkTreeModel *model;
+ GtkTreePath *path;
+ GtkTreeSelection *selection;
+ GList *rows;
+ GtkTreeModel *model;
- g_return_if_fail (view->editable_renderer != NULL);
+ g_return_if_fail (view->editable_renderer != NULL);
- selection = gtk_tree_view_get_selection
- (GTK_TREE_VIEW (view));
- rows = gtk_tree_selection_get_selected_rows (selection, &model);
- if (rows == NULL) return;
+ selection = gtk_tree_view_get_selection
+ (GTK_TREE_VIEW (view));
+ rows = gtk_tree_selection_get_selected_rows (selection, &model);
+ if (rows == NULL) return;
- path = rows->data;
+ path = rows->data;
- g_object_set (G_OBJECT (view->editable_renderer),
- "editable", TRUE,
- NULL);
+ g_object_set (G_OBJECT (view->editable_renderer),
+ "editable", TRUE,
+ NULL);
- gtk_tree_view_set_cursor (GTK_TREE_VIEW (view), path,
- view->editable_column,
- TRUE);
+ gtk_tree_view_set_cursor (GTK_TREE_VIEW (view), path,
+ view->editable_column,
+ TRUE);
- view->edited_node = get_node_from_path (view, path);
- view->remove_if_cancelled = remove_if_cancelled;
+ view->edited_node = get_node_from_path (view, path);
+ view->remove_if_cancelled = remove_if_cancelled;
- g_list_foreach (rows, (GFunc)gtk_tree_path_free, NULL);
- g_list_free (rows);
+ g_list_foreach (rows, (GFunc)gtk_tree_path_free, NULL);
+ g_list_free (rows);
}
/**
@@ -1676,63 +1566,62 @@ ephy_node_view_edit (EphyNodeView *view, gboolean remove_if_cancelled)
gboolean
ephy_node_view_is_target (EphyNodeView *view)
{
- return gtk_widget_is_focus (GTK_WIDGET (view));
+ return gtk_widget_is_focus (GTK_WIDGET (view));
}
static gboolean
filter_visible_func (GtkTreeModel *model, GtkTreeIter *iter, gpointer data)
{
- EphyNode *node;
- EphyNodeView *view = EPHY_NODE_VIEW (data);
+ EphyNode *node;
+ EphyNodeView *view = EPHY_NODE_VIEW (data);
- if (view->filter)
- {
- node = ephy_tree_model_node_node_from_iter (view->nodemodel, iter);
+ if (view->filter) {
+ node = ephy_tree_model_node_node_from_iter (view->nodemodel, iter);
- return ephy_node_filter_evaluate (view->filter, node);
- }
+ return ephy_node_filter_evaluate (view->filter, node);
+ }
- return TRUE;
+ return TRUE;
}
static GObject *
ephy_node_view_constructor (GType type, guint n_construct_properties,
- GObjectConstructParam *construct_params)
-
-{
- GObject *object;
- EphyNodeView *view;
- GtkTreeSelection *selection;
-
- object = G_OBJECT_CLASS (ephy_node_view_parent_class)->constructor (type,
- n_construct_properties,
- construct_params);
- view = EPHY_NODE_VIEW (object);
-
- view->nodemodel = ephy_tree_model_node_new (view->root);
- view->filtermodel = gtk_tree_model_filter_new (GTK_TREE_MODEL (view->nodemodel),
- NULL);
- gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (view->filtermodel),
- filter_visible_func, view, NULL);
- view->sortmodel = ephy_tree_model_sort_new (view->filtermodel);
- gtk_tree_view_set_model (GTK_TREE_VIEW (object), GTK_TREE_MODEL (view->sortmodel));
- g_signal_connect_object (object, "button_press_event",
- G_CALLBACK (ephy_node_view_button_press_cb),
- view, 0);
- g_signal_connect (object, "key_press_event",
- G_CALLBACK (ephy_node_view_key_press_cb),
- view);
- g_signal_connect_object (object, "row_activated",
- G_CALLBACK (ephy_node_view_row_activated_cb),
- view, 0);
-
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (view));
- gtk_tree_selection_set_mode (selection, GTK_SELECTION_MULTIPLE);
- g_signal_connect_object (G_OBJECT (selection), "changed",
- G_CALLBACK (ephy_node_view_selection_changed_cb),
- view, 0);
-
- return object;
+ GObjectConstructParam *construct_params)
+
+{
+ GObject *object;
+ EphyNodeView *view;
+ GtkTreeSelection *selection;
+
+ object = G_OBJECT_CLASS (ephy_node_view_parent_class)->constructor (type,
+ n_construct_properties,
+ construct_params);
+ view = EPHY_NODE_VIEW (object);
+
+ view->nodemodel = ephy_tree_model_node_new (view->root);
+ view->filtermodel = gtk_tree_model_filter_new (GTK_TREE_MODEL (view->nodemodel),
+ NULL);
+ gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (view->filtermodel),
+ filter_visible_func, view, NULL);
+ view->sortmodel = ephy_tree_model_sort_new (view->filtermodel);
+ gtk_tree_view_set_model (GTK_TREE_VIEW (object), GTK_TREE_MODEL (view->sortmodel));
+ g_signal_connect_object (object, "button_press_event",
+ G_CALLBACK (ephy_node_view_button_press_cb),
+ view, 0);
+ g_signal_connect (object, "key_press_event",
+ G_CALLBACK (ephy_node_view_key_press_cb),
+ view);
+ g_signal_connect_object (object, "row_activated",
+ G_CALLBACK (ephy_node_view_row_activated_cb),
+ view, 0);
+
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (view));
+ gtk_tree_selection_set_mode (selection, GTK_SELECTION_MULTIPLE);
+ g_signal_connect_object (G_OBJECT (selection), "changed",
+ G_CALLBACK (ephy_node_view_selection_changed_cb),
+ view, 0);
+
+ return object;
}
/**
@@ -1746,20 +1635,20 @@ ephy_node_view_constructor (GType type, guint n_construct_properties,
**/
void
ephy_node_view_add_toggle (EphyNodeView *view, EphyTreeModelNodeValueFunc value_func,
- gpointer data)
+ gpointer data)
{
- GtkCellRenderer *renderer;
- GtkTreeViewColumn *col;
- int column;
-
- column = ephy_tree_model_node_add_func_column
- (view->nodemodel, G_TYPE_BOOLEAN, value_func, data);
- view->toggle_column = column;
-
- renderer = gtk_cell_renderer_toggle_new ();
- col = gtk_tree_view_column_new_with_attributes
- ("", renderer, "active", column, NULL);
- gtk_tree_view_append_column (GTK_TREE_VIEW (view), col);
+ GtkCellRenderer *renderer;
+ GtkTreeViewColumn *col;
+ int column;
+
+ column = ephy_tree_model_node_add_func_column
+ (view->nodemodel, G_TYPE_BOOLEAN, value_func, data);
+ view->toggle_column = column;
+
+ renderer = gtk_cell_renderer_toggle_new ();
+ col = gtk_tree_view_column_new_with_attributes
+ ("", renderer, "active", column, NULL);
+ gtk_tree_view_append_column (GTK_TREE_VIEW (view), col);
}
/**
@@ -1772,165 +1661,161 @@ ephy_node_view_add_toggle (EphyNodeView *view, EphyTreeModelNodeValueFunc value_
void
ephy_node_view_popup (EphyNodeView *view, GtkWidget *menu)
{
- GdkEvent *event;
-
- event = gtk_get_current_event ();
- if (event)
- {
- if (event->type == GDK_KEY_PRESS)
- {
- GdkEventKey *key = (GdkEventKey *) event;
-
- gtk_menu_popup (GTK_MENU (menu), NULL, NULL,
- ephy_gui_menu_position_tree_selection,
- view, 0, key->time);
- gtk_menu_shell_select_first (GTK_MENU_SHELL (menu), FALSE);
- }
- else if (event->type == GDK_BUTTON_PRESS)
- {
- GdkEventButton *button = (GdkEventButton *) event;
-
- gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL,
- NULL, button->button, button->time);
- }
-
- gdk_event_free (event);
- }
+ GdkEvent *event;
+
+ event = gtk_get_current_event ();
+ if (event) {
+ if (event->type == GDK_KEY_PRESS) {
+ GdkEventKey *key = (GdkEventKey *)event;
+
+ gtk_menu_popup (GTK_MENU (menu), NULL, NULL,
+ ephy_gui_menu_position_tree_selection,
+ view, 0, key->time);
+ gtk_menu_shell_select_first (GTK_MENU_SHELL (menu), FALSE);
+ } else if (event->type == GDK_BUTTON_PRESS) {
+ GdkEventButton *button = (GdkEventButton *)event;
+
+ gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL,
+ NULL, button->button, button->time);
+ }
+
+ gdk_event_free (event);
+ }
}
gboolean
ephy_node_view_get_iter_for_node (EphyNodeView *view,
- GtkTreeIter *iter,
- EphyNode *node)
+ GtkTreeIter *iter,
+ EphyNode *node)
{
- GtkTreeIter node_iter, filter_iter;
+ GtkTreeIter node_iter, filter_iter;
- ephy_tree_model_node_iter_from_node (EPHY_TREE_MODEL_NODE (view->nodemodel), node, &node_iter);
- if (!gtk_tree_model_filter_convert_child_iter_to_iter (GTK_TREE_MODEL_FILTER (view->filtermodel),
- &filter_iter, &node_iter))
- return FALSE;
+ ephy_tree_model_node_iter_from_node (EPHY_TREE_MODEL_NODE (view->nodemodel), node, &node_iter);
+ if (!gtk_tree_model_filter_convert_child_iter_to_iter (GTK_TREE_MODEL_FILTER (view->filtermodel),
+ &filter_iter, &node_iter))
+ return FALSE;
- if (!gtk_tree_model_sort_convert_child_iter_to_iter (GTK_TREE_MODEL_SORT (view->sortmodel),
- iter, &filter_iter))
- return FALSE;
+ if (!gtk_tree_model_sort_convert_child_iter_to_iter (GTK_TREE_MODEL_SORT (view->sortmodel),
+ iter, &filter_iter))
+ return FALSE;
- return TRUE;
+ return TRUE;
}
static void
ephy_node_view_class_init (EphyNodeViewClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- object_class->constructor = ephy_node_view_constructor;
- object_class->finalize = ephy_node_view_finalize;
-
- object_class->set_property = ephy_node_view_set_property;
- object_class->get_property = ephy_node_view_get_property;
-
- /**
- * EphyNodeView:root:
- *
- * A #gpointer to the root node of the #EphyNode elements of the view.
- */
- obj_properties[PROP_ROOT] =
- g_param_spec_pointer ("root",
- "Root node",
- "Root node",
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY);
-
- /**
- * EphyNodeView:filter:
- *
- * An #EphyNodeFilter object to use in the view.
- */
- obj_properties[PROP_FILTER] =
- g_param_spec_object ("filter",
- "Filter object",
- "Filter object",
- EPHY_TYPE_NODE_FILTER,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
-
- g_object_class_install_properties (object_class, LAST_PROP, obj_properties);
-
- /**
- * EphyNodeView::node-toggled:
- * @view: the object on which the signal is emitted
- * @node: the target #EphyNode
- * @checked: the new value of the toggle column
- *
- * Emitted when a row value is toggled, only emitted for toggle columns.
- */
- ephy_node_view_signals[NODE_TOGGLED] =
- g_signal_new ("node_toggled",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- 0, NULL, NULL, NULL,
- G_TYPE_NONE,
- 2,
- G_TYPE_POINTER,
- G_TYPE_BOOLEAN);
- /**
- * EphyNodeView::node-activated:
- * @view: the object on which the signal is emitted
- * @node: the activated #EphyNode
- *
- * Emitted when a row is activated.
- */
- ephy_node_view_signals[NODE_ACTIVATED] =
- g_signal_new ("node_activated",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- 0, NULL, NULL, NULL,
- G_TYPE_NONE,
- 1,
- G_TYPE_POINTER);
- /**
- * EphyNodeView::node-selected:
- * @view: the object on which the signal is emitted
- * @node: the selected #EphyNode
- *
- * Emitted when a row is selected.
- */
- ephy_node_view_signals[NODE_SELECTED] =
- g_signal_new ("node_selected",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- 0, NULL, NULL, NULL,
- G_TYPE_NONE,
- 1,
- G_TYPE_POINTER);
- /**
- * EphyNodeView::node-dropped:
- * @view: the object on which the signal is emitted
- * @node: the dropped #EphyNode
- * @uris: URIs from the dragged data
- *
- * Emitted when an #EphyNode is dropped into the #EphyNodeView.
- */
- ephy_node_view_signals[NODE_DROPPED] =
- g_signal_new ("node_dropped",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- 0, NULL, NULL, NULL,
- G_TYPE_NONE,
- 2,
- G_TYPE_POINTER,
- G_TYPE_POINTER);
-
- /**
- * EphyNodeView::node-middle-clicked:
- * @view: the object on which the signal is emitted
- * @node: the clicked #EphyNode
- *
- * Emitted when the user middle clicks on a row of the #EphyNodeView.
- */
- ephy_node_view_signals[NODE_MIDDLE_CLICKED] =
- g_signal_new ("node_middle_clicked",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- 0, NULL, NULL, NULL,
- G_TYPE_NONE,
- 1,
- G_TYPE_POINTER);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->constructor = ephy_node_view_constructor;
+ object_class->finalize = ephy_node_view_finalize;
+
+ object_class->set_property = ephy_node_view_set_property;
+ object_class->get_property = ephy_node_view_get_property;
+
+ /**
+ * EphyNodeView:root:
+ *
+ * A #gpointer to the root node of the #EphyNode elements of the view.
+ */
+ obj_properties[PROP_ROOT] =
+ g_param_spec_pointer ("root",
+ "Root node",
+ "Root node",
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY);
+
+ /**
+ * EphyNodeView:filter:
+ *
+ * An #EphyNodeFilter object to use in the view.
+ */
+ obj_properties[PROP_FILTER] =
+ g_param_spec_object ("filter",
+ "Filter object",
+ "Filter object",
+ EPHY_TYPE_NODE_FILTER,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+
+ g_object_class_install_properties (object_class, LAST_PROP, obj_properties);
+
+ /**
+ * EphyNodeView::node-toggled:
+ * @view: the object on which the signal is emitted
+ * @node: the target #EphyNode
+ * @checked: the new value of the toggle column
+ *
+ * Emitted when a row value is toggled, only emitted for toggle columns.
+ */
+ ephy_node_view_signals[NODE_TOGGLED] =
+ g_signal_new ("node_toggled",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL, NULL,
+ G_TYPE_NONE,
+ 2,
+ G_TYPE_POINTER,
+ G_TYPE_BOOLEAN);
+ /**
+ * EphyNodeView::node-activated:
+ * @view: the object on which the signal is emitted
+ * @node: the activated #EphyNode
+ *
+ * Emitted when a row is activated.
+ */
+ ephy_node_view_signals[NODE_ACTIVATED] =
+ g_signal_new ("node_activated",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL, NULL,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_POINTER);
+ /**
+ * EphyNodeView::node-selected:
+ * @view: the object on which the signal is emitted
+ * @node: the selected #EphyNode
+ *
+ * Emitted when a row is selected.
+ */
+ ephy_node_view_signals[NODE_SELECTED] =
+ g_signal_new ("node_selected",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL, NULL,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_POINTER);
+ /**
+ * EphyNodeView::node-dropped:
+ * @view: the object on which the signal is emitted
+ * @node: the dropped #EphyNode
+ * @uris: URIs from the dragged data
+ *
+ * Emitted when an #EphyNode is dropped into the #EphyNodeView.
+ */
+ ephy_node_view_signals[NODE_DROPPED] =
+ g_signal_new ("node_dropped",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL, NULL,
+ G_TYPE_NONE,
+ 2,
+ G_TYPE_POINTER,
+ G_TYPE_POINTER);
+
+ /**
+ * EphyNodeView::node-middle-clicked:
+ * @view: the object on which the signal is emitted
+ * @node: the clicked #EphyNode
+ *
+ * Emitted when the user middle clicks on a row of the #EphyNodeView.
+ */
+ ephy_node_view_signals[NODE_MIDDLE_CLICKED] =
+ g_signal_new ("node_middle_clicked",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL, NULL,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_POINTER);
}
diff --git a/lib/widgets/ephy-security-popover.c b/lib/widgets/ephy-security-popover.c
index e1003b691..4e2c76bd8 100644
--- a/lib/widgets/ephy-security-popover.c
+++ b/lib/widgets/ephy-security-popover.c
@@ -34,8 +34,7 @@
* can also be used to show that a connection does not use TLS at all.
*/
-enum
-{
+enum {
PROP_0,
PROP_ADDRESS,
PROP_CERTIFICATE,
@@ -46,8 +45,7 @@ enum
static GParamSpec *obj_properties[LAST_PROP];
-struct _EphySecurityPopover
-{
+struct _EphySecurityPopover {
GtkPopover parent_instance;
char *address;
char *hostname;
@@ -64,7 +62,7 @@ G_DEFINE_TYPE (EphySecurityPopover, ephy_security_popover, GTK_TYPE_POPOVER)
static void
ephy_security_popover_set_address (EphySecurityPopover *popover,
- const char *address)
+ const char *address)
{
SoupURI *uri;
char *label_text;
@@ -86,7 +84,7 @@ ephy_security_popover_set_address (EphySecurityPopover *popover,
static void
ephy_security_popover_set_certificate (EphySecurityPopover *popover,
- GTlsCertificate *certificate)
+ GTlsCertificate *certificate)
{
if (certificate)
popover->certificate = g_object_ref (certificate);
@@ -94,7 +92,7 @@ ephy_security_popover_set_certificate (EphySecurityPopover *popover,
static void
ephy_security_popover_set_security_level (EphySecurityPopover *popover,
- EphySecurityLevel security_level)
+ EphySecurityLevel security_level)
{
GIcon *icon;
char *address_text;
@@ -105,38 +103,38 @@ ephy_security_popover_set_security_level (EphySecurityPopover *popover,
address_text = g_markup_printf_escaped ("<span weight=\"bold\">%s</span>", popover->hostname);
switch (security_level) {
- case EPHY_SECURITY_LEVEL_UNACCEPTABLE_CERTIFICATE:
- /* Label in certificate popover when site is untrusted. %s is a URL. */
- label_text = g_strdup_printf (_("This web site’s digital identification is not trusted. "
- "You may have connected to an attacker pretending to be %s."),
- address_text);
- gtk_label_set_markup (GTK_LABEL (popover->security_label), label_text);
- gtk_widget_hide (popover->host_label);
- break;
- case EPHY_SECURITY_LEVEL_NO_SECURITY:
- /* Label in certificate popover when site uses HTTP. %s is a URL. */
- label_text = g_strdup_printf (_("%s has no security. An attacker could see any information "
- "you send, or control the content that you see."),
- address_text);
- gtk_label_set_markup (GTK_LABEL (popover->security_label), label_text);
- gtk_widget_hide (popover->host_label);
- break;
- case EPHY_SECURITY_LEVEL_MIXED_CONTENT:
- gtk_label_set_text (GTK_LABEL (popover->security_label),
- /* Label in certificate popover when site sends mixed content. */
- _("This web site did not properly secure your connection."));
- gtk_widget_show (popover->host_label);
- break;
- case EPHY_SECURITY_LEVEL_STRONG_SECURITY:
- gtk_label_set_text (GTK_LABEL (popover->security_label),
- /* Label in certificate popover on secure sites. */
- _("Your connection seems to be secure."));
- gtk_widget_show (popover->host_label);
- break;
- case EPHY_SECURITY_LEVEL_TO_BE_DETERMINED:
- case EPHY_SECURITY_LEVEL_LOCAL_PAGE:
- default:
- g_assert_not_reached ();
+ case EPHY_SECURITY_LEVEL_UNACCEPTABLE_CERTIFICATE:
+ /* Label in certificate popover when site is untrusted. %s is a URL. */
+ label_text = g_strdup_printf (_("This web site’s digital identification is not trusted. "
+ "You may have connected to an attacker pretending to be %s."),
+ address_text);
+ gtk_label_set_markup (GTK_LABEL (popover->security_label), label_text);
+ gtk_widget_hide (popover->host_label);
+ break;
+ case EPHY_SECURITY_LEVEL_NO_SECURITY:
+ /* Label in certificate popover when site uses HTTP. %s is a URL. */
+ label_text = g_strdup_printf (_("%s has no security. An attacker could see any information "
+ "you send, or control the content that you see."),
+ address_text);
+ gtk_label_set_markup (GTK_LABEL (popover->security_label), label_text);
+ gtk_widget_hide (popover->host_label);
+ break;
+ case EPHY_SECURITY_LEVEL_MIXED_CONTENT:
+ gtk_label_set_text (GTK_LABEL (popover->security_label),
+ /* Label in certificate popover when site sends mixed content. */
+ _("This web site did not properly secure your connection."));
+ gtk_widget_show (popover->host_label);
+ break;
+ case EPHY_SECURITY_LEVEL_STRONG_SECURITY:
+ gtk_label_set_text (GTK_LABEL (popover->security_label),
+ /* Label in certificate popover on secure sites. */
+ _("Your connection seems to be secure."));
+ gtk_widget_show (popover->host_label);
+ break;
+ case EPHY_SECURITY_LEVEL_TO_BE_DETERMINED:
+ case EPHY_SECURITY_LEVEL_LOCAL_PAGE:
+ default:
+ g_assert_not_reached ();
}
icon = g_themed_icon_new_with_default_fallbacks (ephy_security_level_to_icon_name (security_level));
@@ -149,7 +147,7 @@ ephy_security_popover_set_security_level (EphySecurityPopover *popover,
static void
certificate_button_clicked_cb (GtkButton *button,
- gpointer user_data)
+ gpointer user_data)
{
EphySecurityPopover *popover = EPHY_SECURITY_POPOVER (user_data);
GtkWidget *dialog;
@@ -214,42 +212,42 @@ ephy_security_popover_finalize (GObject *object)
}
static void
-ephy_security_popover_set_property (GObject *object,
- guint prop_id,
+ephy_security_popover_set_property (GObject *object,
+ guint prop_id,
const GValue *value,
- GParamSpec *pspec)
+ GParamSpec *pspec)
{
EphySecurityPopover *popover = EPHY_SECURITY_POPOVER (object);
switch (prop_id) {
- case PROP_ADDRESS:
- ephy_security_popover_set_address (popover, g_value_get_string (value));
- break;
- case PROP_CERTIFICATE:
- ephy_security_popover_set_certificate (popover, g_value_get_object (value));
- break;
- case PROP_SECURITY_LEVEL:
- ephy_security_popover_set_security_level (popover, g_value_get_enum (value));
- break;
- case PROP_TLS_ERRORS:
- popover->tls_errors = g_value_get_flags (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ case PROP_ADDRESS:
+ ephy_security_popover_set_address (popover, g_value_get_string (value));
+ break;
+ case PROP_CERTIFICATE:
+ ephy_security_popover_set_certificate (popover, g_value_get_object (value));
+ break;
+ case PROP_SECURITY_LEVEL:
+ ephy_security_popover_set_security_level (popover, g_value_get_enum (value));
+ break;
+ case PROP_TLS_ERRORS:
+ popover->tls_errors = g_value_get_flags (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
static void
ephy_security_popover_get_preferred_width (GtkWidget *widget,
- gint *minimum_width,
- gint *natural_width)
+ gint *minimum_width,
+ gint *natural_width)
{
GTK_WIDGET_CLASS (ephy_security_popover_parent_class)->get_preferred_width (widget,
- minimum_width,
- natural_width);
+ minimum_width,
+ natural_width);
if (*natural_width > 600)
- *natural_width = MAX(600, *minimum_width);
+ *natural_width = MAX (600, *minimum_width);
}
static void
@@ -342,11 +340,11 @@ ephy_security_popover_init (EphySecurityPopover *popover)
gtk_widget_show_all (popover->grid);
}
-GtkWidget *ephy_security_popover_new (GtkWidget *relative_to,
- const char *address,
- GTlsCertificate *certificate,
+GtkWidget *ephy_security_popover_new (GtkWidget *relative_to,
+ const char *address,
+ GTlsCertificate *certificate,
GTlsCertificateFlags tls_errors,
- EphySecurityLevel security_level)
+ EphySecurityLevel security_level)
{
g_return_val_if_fail (address != NULL, NULL);
diff --git a/lib/widgets/ephy-tree-model-node.c b/lib/widgets/ephy-tree-model-node.c
index bca8a3684..d43c45378 100644
--- a/lib/widgets/ephy-tree-model-node.c
+++ b/lib/widgets/ephy-tree-model-node.c
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright © 2002 Jorn Baayen <jorn@nl.linux.org>
*
* This program is free software; you can redistribute it and/or modify
@@ -36,31 +36,28 @@
static void ephy_tree_model_node_finalize (GObject *object);
static void ephy_tree_model_node_tree_model_interface_init (GtkTreeModelIface *iface);
-struct _EphyTreeModelNode
-{
- GObject parent_instance;
+struct _EphyTreeModelNode {
+ GObject parent_instance;
- EphyNode *root;
+ EphyNode *root;
- GPtrArray *columns;
- int columns_num;
+ GPtrArray *columns;
+ int columns_num;
- int stamp;
+ int stamp;
};
-typedef struct
-{
- GType type;
- int prop_id;
- EphyTreeModelNodeValueFunc func;
- gpointer user_data;
+typedef struct {
+ GType type;
+ int prop_id;
+ EphyTreeModelNodeValueFunc func;
+ gpointer user_data;
} EphyTreeModelNodeColData;
-enum
-{
- PROP_0,
- PROP_ROOT,
- LAST_PROP
+enum {
+ PROP_0,
+ PROP_ROOT,
+ LAST_PROP
};
static GParamSpec *obj_properties[LAST_PROP];
@@ -70,204 +67,199 @@ G_DEFINE_TYPE_WITH_CODE (EphyTreeModelNode, ephy_tree_model_node, G_TYPE_OBJECT,
ephy_tree_model_node_tree_model_interface_init))
static void
-root_child_removed_cb (EphyNode *node,
- EphyNode *child,
- guint old_index,
- EphyTreeModelNode *model)
+root_child_removed_cb (EphyNode *node,
+ EphyNode *child,
+ guint old_index,
+ EphyTreeModelNode *model)
{
- GtkTreePath *path;
+ GtkTreePath *path;
- path = gtk_tree_path_new ();
- gtk_tree_path_append_index (path, old_index);
- gtk_tree_model_row_deleted (GTK_TREE_MODEL (model), path);
- gtk_tree_path_free (path);
+ path = gtk_tree_path_new ();
+ gtk_tree_path_append_index (path, old_index);
+ gtk_tree_model_row_deleted (GTK_TREE_MODEL (model), path);
+ gtk_tree_path_free (path);
}
static inline GtkTreePath *
get_path_real (EphyTreeModelNode *model,
- EphyNode *node)
+ EphyNode *node)
{
- GtkTreePath *retval;
+ GtkTreePath *retval;
- retval = gtk_tree_path_new ();
- gtk_tree_path_append_index (retval, ephy_node_get_child_index (model->root, node));
+ retval = gtk_tree_path_new ();
+ gtk_tree_path_append_index (retval, ephy_node_get_child_index (model->root, node));
- return retval;
+ return retval;
}
static void
-root_child_added_cb (EphyNode *node,
- EphyNode *child,
- EphyTreeModelNode *model)
+root_child_added_cb (EphyNode *node,
+ EphyNode *child,
+ EphyTreeModelNode *model)
{
- GtkTreePath *path;
- GtkTreeIter iter;
+ GtkTreePath *path;
+ GtkTreeIter iter;
- ephy_tree_model_node_iter_from_node (model, child, &iter);
+ ephy_tree_model_node_iter_from_node (model, child, &iter);
- path = get_path_real (model, child);
- gtk_tree_model_row_inserted (GTK_TREE_MODEL (model), path, &iter);
- gtk_tree_path_free (path);
+ path = get_path_real (model, child);
+ gtk_tree_model_row_inserted (GTK_TREE_MODEL (model), path, &iter);
+ gtk_tree_path_free (path);
}
static inline void
ephy_tree_model_node_update_node (EphyTreeModelNode *model,
- EphyNode *node,
- int idx)
+ EphyNode *node,
+ int idx)
{
- GtkTreePath *path;
- GtkTreeIter iter;
+ GtkTreePath *path;
+ GtkTreeIter iter;
- ephy_tree_model_node_iter_from_node (model, node, &iter);
+ ephy_tree_model_node_iter_from_node (model, node, &iter);
- if (idx >= 0)
- {
- path = gtk_tree_path_new ();
- gtk_tree_path_append_index (path, idx);
- }
- else
- {
- path = get_path_real (model, node);
- }
+ if (idx >= 0) {
+ path = gtk_tree_path_new ();
+ gtk_tree_path_append_index (path, idx);
+ } else {
+ path = get_path_real (model, node);
+ }
- LOG ("Updating row");
+ LOG ("Updating row");
- gtk_tree_model_row_changed (GTK_TREE_MODEL (model), path, &iter);
- gtk_tree_path_free (path);
+ gtk_tree_model_row_changed (GTK_TREE_MODEL (model), path, &iter);
+ gtk_tree_path_free (path);
}
static void
-root_child_changed_cb (EphyNode *node,
- EphyNode *child,
- guint property_id,
- EphyTreeModelNode *model)
+root_child_changed_cb (EphyNode *node,
+ EphyNode *child,
+ guint property_id,
+ EphyTreeModelNode *model)
{
- ephy_tree_model_node_update_node (model, child, -1);
+ ephy_tree_model_node_update_node (model, child, -1);
}
static void
-root_children_reordered_cb (EphyNode *node,
- int *new_order,
- EphyTreeModelNode *model)
+root_children_reordered_cb (EphyNode *node,
+ int *new_order,
+ EphyTreeModelNode *model)
{
- GtkTreePath *path;
+ GtkTreePath *path;
- path = gtk_tree_path_new ();
- gtk_tree_model_rows_reordered (GTK_TREE_MODEL (model), path, NULL, new_order);
- gtk_tree_path_free (path);
+ path = gtk_tree_path_new ();
+ gtk_tree_model_rows_reordered (GTK_TREE_MODEL (model), path, NULL, new_order);
+ gtk_tree_path_free (path);
}
static void
-root_destroy_cb (EphyNode *node,
- EphyTreeModelNode *model)
+root_destroy_cb (EphyNode *node,
+ EphyTreeModelNode *model)
{
- model->root = NULL;
+ model->root = NULL;
- /* no need to do other stuff since we should have had a bunch of child_removed
- * signals already */
+ /* no need to do other stuff since we should have had a bunch of child_removed
+ * signals already */
}
static void
-ephy_tree_model_node_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- EphyTreeModelNode *model = EPHY_TREE_MODEL_NODE (object);
-
- switch (prop_id)
- {
- case PROP_ROOT:
- model->root = g_value_get_pointer (value);
-
- ephy_node_signal_connect_object (model->root,
- EPHY_NODE_CHILD_ADDED,
- (EphyNodeCallback) root_child_added_cb,
- G_OBJECT (model));
- ephy_node_signal_connect_object (model->root,
- EPHY_NODE_CHILD_REMOVED,
- (EphyNodeCallback) root_child_removed_cb,
- G_OBJECT (model));
- ephy_node_signal_connect_object (model->root,
- EPHY_NODE_CHILD_CHANGED,
- (EphyNodeCallback) root_child_changed_cb,
- G_OBJECT (model));
- ephy_node_signal_connect_object (model->root,
- EPHY_NODE_CHILDREN_REORDERED,
- (EphyNodeCallback) root_children_reordered_cb,
- G_OBJECT (model));
- ephy_node_signal_connect_object (model->root,
- EPHY_NODE_DESTROY,
- (EphyNodeCallback) root_destroy_cb,
- G_OBJECT (model));
-
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ephy_tree_model_node_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ EphyTreeModelNode *model = EPHY_TREE_MODEL_NODE (object);
+
+ switch (prop_id) {
+ case PROP_ROOT:
+ model->root = g_value_get_pointer (value);
+
+ ephy_node_signal_connect_object (model->root,
+ EPHY_NODE_CHILD_ADDED,
+ (EphyNodeCallback)root_child_added_cb,
+ G_OBJECT (model));
+ ephy_node_signal_connect_object (model->root,
+ EPHY_NODE_CHILD_REMOVED,
+ (EphyNodeCallback)root_child_removed_cb,
+ G_OBJECT (model));
+ ephy_node_signal_connect_object (model->root,
+ EPHY_NODE_CHILD_CHANGED,
+ (EphyNodeCallback)root_child_changed_cb,
+ G_OBJECT (model));
+ ephy_node_signal_connect_object (model->root,
+ EPHY_NODE_CHILDREN_REORDERED,
+ (EphyNodeCallback)root_children_reordered_cb,
+ G_OBJECT (model));
+ ephy_node_signal_connect_object (model->root,
+ EPHY_NODE_DESTROY,
+ (EphyNodeCallback)root_destroy_cb,
+ G_OBJECT (model));
+
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
-ephy_tree_model_node_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- EphyTreeModelNode *model = EPHY_TREE_MODEL_NODE (object);
-
- switch (prop_id)
- {
- case PROP_ROOT:
- g_value_set_pointer (value, model->root);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ephy_tree_model_node_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ EphyTreeModelNode *model = EPHY_TREE_MODEL_NODE (object);
+
+ switch (prop_id) {
+ case PROP_ROOT:
+ g_value_set_pointer (value, model->root);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
ephy_tree_model_node_class_init (EphyTreeModelNodeClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = ephy_tree_model_node_finalize;
+ object_class->finalize = ephy_tree_model_node_finalize;
- object_class->set_property = ephy_tree_model_node_set_property;
- object_class->get_property = ephy_tree_model_node_get_property;
+ object_class->set_property = ephy_tree_model_node_set_property;
+ object_class->get_property = ephy_tree_model_node_get_property;
- /**
- * EphyTreeModelNode:root:
- *
- * The root #EphyNode of the model.
- */
- obj_properties[PROP_ROOT] =
- g_param_spec_pointer ("root",
- "Root node",
- "Root node",
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY);
+ /**
+ * EphyTreeModelNode:root:
+ *
+ * The root #EphyNode of the model.
+ */
+ obj_properties[PROP_ROOT] =
+ g_param_spec_pointer ("root",
+ "Root node",
+ "Root node",
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY);
- g_object_class_install_properties (object_class, LAST_PROP, obj_properties);
+ g_object_class_install_properties (object_class, LAST_PROP, obj_properties);
}
static void
ephy_tree_model_node_init (EphyTreeModelNode *model)
{
- model->stamp = g_random_int ();
- model->columns = g_ptr_array_new ();
- model->columns_num = 0;
+ model->stamp = g_random_int ();
+ model->columns = g_ptr_array_new ();
+ model->columns_num = 0;
}
static void
ephy_tree_model_node_finalize (GObject *object)
{
- EphyTreeModelNode *model = EPHY_TREE_MODEL_NODE (object);
+ EphyTreeModelNode *model = EPHY_TREE_MODEL_NODE (object);
- g_ptr_array_foreach (model->columns, (GFunc) g_free, NULL);
- g_ptr_array_free (model->columns, TRUE);
+ g_ptr_array_foreach (model->columns, (GFunc)g_free, NULL);
+ g_ptr_array_free (model->columns, TRUE);
- G_OBJECT_CLASS (ephy_tree_model_node_parent_class)->finalize (object);
+ G_OBJECT_CLASS (ephy_tree_model_node_parent_class)->finalize (object);
}
/**
@@ -281,13 +273,13 @@ ephy_tree_model_node_finalize (GObject *object)
EphyTreeModelNode *
ephy_tree_model_node_new (EphyNode *root)
{
- EphyTreeModelNode *model;
+ EphyTreeModelNode *model;
- model = EPHY_TREE_MODEL_NODE (g_object_new (EPHY_TYPE_TREE_MODEL_NODE,
- "root", root,
- NULL));
+ model = EPHY_TREE_MODEL_NODE (g_object_new (EPHY_TYPE_TREE_MODEL_NODE,
+ "root", root,
+ NULL));
- return model;
+ return model;
}
/**
@@ -304,26 +296,26 @@ ephy_tree_model_node_new (EphyNode *root)
* Returns: the id of the new column
**/
int
-ephy_tree_model_node_add_column_full (EphyTreeModelNode *model,
- GType value_type,
- int prop_id,
- EphyTreeModelNodeValueFunc func,
- gpointer user_data)
-{
- EphyTreeModelNodeColData *col;
- int col_id;
-
- col = g_new0 (EphyTreeModelNodeColData, 1);
- col->prop_id = prop_id;
- col->type = value_type;
- col->func = func;
- col->user_data = user_data;
-
- g_ptr_array_add (model->columns, col);
- col_id = model->columns_num;
- model->columns_num++;
-
- return col_id;
+ephy_tree_model_node_add_column_full (EphyTreeModelNode *model,
+ GType value_type,
+ int prop_id,
+ EphyTreeModelNodeValueFunc func,
+ gpointer user_data)
+{
+ EphyTreeModelNodeColData *col;
+ int col_id;
+
+ col = g_new0 (EphyTreeModelNodeColData, 1);
+ col->prop_id = prop_id;
+ col->type = value_type;
+ col->func = func;
+ col->user_data = user_data;
+
+ g_ptr_array_add (model->columns, col);
+ col_id = model->columns_num;
+ model->columns_num++;
+
+ return col_id;
}
@@ -339,10 +331,10 @@ ephy_tree_model_node_add_column_full (EphyTreeModelNode *model,
**/
int
ephy_tree_model_node_add_prop_column (EphyTreeModelNode *model,
- GType value_type,
- int prop_id)
+ GType value_type,
+ int prop_id)
{
- return ephy_tree_model_node_add_column_full (model, value_type, prop_id, NULL, NULL);
+ return ephy_tree_model_node_add_column_full (model, value_type, prop_id, NULL, NULL);
}
/**
@@ -357,237 +349,230 @@ ephy_tree_model_node_add_prop_column (EphyTreeModelNode *model,
* Returns: the id of the new column
**/
int
-ephy_tree_model_node_add_func_column (EphyTreeModelNode *model,
- GType value_type,
- EphyTreeModelNodeValueFunc func,
- gpointer user_data)
+ephy_tree_model_node_add_func_column (EphyTreeModelNode *model,
+ GType value_type,
+ EphyTreeModelNodeValueFunc func,
+ gpointer user_data)
{
- return ephy_tree_model_node_add_column_full (model, value_type, -1, func, user_data);
+ return ephy_tree_model_node_add_column_full (model, value_type, -1, func, user_data);
}
static int
ephy_tree_model_node_get_n_columns (GtkTreeModel *tree_model)
{
- EphyTreeModelNode *model = EPHY_TREE_MODEL_NODE (tree_model);
+ EphyTreeModelNode *model = EPHY_TREE_MODEL_NODE (tree_model);
- return model->columns_num;
+ return model->columns_num;
}
static GType
ephy_tree_model_node_get_column_type (GtkTreeModel *tree_model,
- int index)
+ int index)
{
- EphyTreeModelNodeColData *col;
- EphyTreeModelNode *model = EPHY_TREE_MODEL_NODE (tree_model);
+ EphyTreeModelNodeColData *col;
+ EphyTreeModelNode *model = EPHY_TREE_MODEL_NODE (tree_model);
- col = g_ptr_array_index (model->columns, index);
+ col = g_ptr_array_index (model->columns, index);
- return col->type;
+ return col->type;
}
static void
ephy_tree_model_node_get_value (GtkTreeModel *tree_model,
- GtkTreeIter *iter,
- int column,
- GValue *value)
+ GtkTreeIter *iter,
+ int column,
+ GValue *value)
{
- EphyTreeModelNodeColData *col;
- EphyTreeModelNode *model = EPHY_TREE_MODEL_NODE (tree_model);
- EphyNode *node;
-
- g_return_if_fail (EPHY_IS_TREE_MODEL_NODE (tree_model));
- g_return_if_fail (iter != NULL);
- g_return_if_fail (iter->stamp == model->stamp);
-
- if (model->root == NULL)
- return;
-
- node = iter->user_data;
-
- col = g_ptr_array_index (model->columns, column);
-
- g_return_if_fail (col != NULL);
-
- if (col->prop_id >= 0)
- {
- if (!ephy_node_get_property (node, col->prop_id, value))
- {
- /* make sure to return a valid string anyway */
- g_value_init (value, col->type);
- if (col->type == G_TYPE_STRING)
- {
- g_value_set_string (value, "");
- }
- }
- }
-
- if (col->func)
- {
- col->func (node, value, col->user_data);
- }
+ EphyTreeModelNodeColData *col;
+ EphyTreeModelNode *model = EPHY_TREE_MODEL_NODE (tree_model);
+ EphyNode *node;
+
+ g_return_if_fail (EPHY_IS_TREE_MODEL_NODE (tree_model));
+ g_return_if_fail (iter != NULL);
+ g_return_if_fail (iter->stamp == model->stamp);
+
+ if (model->root == NULL)
+ return;
+
+ node = iter->user_data;
+
+ col = g_ptr_array_index (model->columns, column);
+
+ g_return_if_fail (col != NULL);
+
+ if (col->prop_id >= 0) {
+ if (!ephy_node_get_property (node, col->prop_id, value)) {
+ /* make sure to return a valid string anyway */
+ g_value_init (value, col->type);
+ if (col->type == G_TYPE_STRING) {
+ g_value_set_string (value, "");
+ }
+ }
+ }
+
+ if (col->func) {
+ col->func (node, value, col->user_data);
+ }
}
static GtkTreeModelFlags
ephy_tree_model_node_get_flags (GtkTreeModel *tree_model)
{
- return GTK_TREE_MODEL_ITERS_PERSIST | GTK_TREE_MODEL_LIST_ONLY;
+ return GTK_TREE_MODEL_ITERS_PERSIST | GTK_TREE_MODEL_LIST_ONLY;
}
static gboolean
ephy_tree_model_node_get_iter (GtkTreeModel *tree_model,
- GtkTreeIter *iter,
- GtkTreePath *path)
+ GtkTreeIter *iter,
+ GtkTreePath *path)
{
- EphyTreeModelNode *model = EPHY_TREE_MODEL_NODE (tree_model);
- int i;
+ EphyTreeModelNode *model = EPHY_TREE_MODEL_NODE (tree_model);
+ int i;
- g_return_val_if_fail (EPHY_IS_TREE_MODEL_NODE (model), FALSE);
- g_return_val_if_fail (gtk_tree_path_get_depth (path) > 0, FALSE);
+ g_return_val_if_fail (EPHY_IS_TREE_MODEL_NODE (model), FALSE);
+ g_return_val_if_fail (gtk_tree_path_get_depth (path) > 0, FALSE);
- if (model->root == NULL)
- return FALSE;
+ if (model->root == NULL)
+ return FALSE;
- i = gtk_tree_path_get_indices (path)[0];
+ i = gtk_tree_path_get_indices (path)[0];
- iter->stamp = model->stamp;
- iter->user_data = ephy_node_get_nth_child (model->root, i);
+ iter->stamp = model->stamp;
+ iter->user_data = ephy_node_get_nth_child (model->root, i);
- if (iter->user_data == NULL)
- {
- iter->stamp = 0;
- return FALSE;
- }
+ if (iter->user_data == NULL) {
+ iter->stamp = 0;
+ return FALSE;
+ }
- return TRUE;
+ return TRUE;
}
static GtkTreePath *
ephy_tree_model_node_get_path (GtkTreeModel *tree_model,
- GtkTreeIter *iter)
+ GtkTreeIter *iter)
{
- EphyTreeModelNode *model = EPHY_TREE_MODEL_NODE (tree_model);
- EphyNode *node;
+ EphyTreeModelNode *model = EPHY_TREE_MODEL_NODE (tree_model);
+ EphyNode *node;
- g_return_val_if_fail (EPHY_IS_TREE_MODEL_NODE (tree_model), NULL);
- g_return_val_if_fail (iter != NULL, NULL);
- g_return_val_if_fail (iter->user_data != NULL, NULL);
- g_return_val_if_fail (iter->stamp == model->stamp, NULL);
+ g_return_val_if_fail (EPHY_IS_TREE_MODEL_NODE (tree_model), NULL);
+ g_return_val_if_fail (iter != NULL, NULL);
+ g_return_val_if_fail (iter->user_data != NULL, NULL);
+ g_return_val_if_fail (iter->stamp == model->stamp, NULL);
- if (model->root == NULL)
- return NULL;
+ if (model->root == NULL)
+ return NULL;
- node = iter->user_data;
+ node = iter->user_data;
- if (node == model->root)
- return gtk_tree_path_new ();
+ if (node == model->root)
+ return gtk_tree_path_new ();
- return get_path_real (model, node);
+ return get_path_real (model, node);
}
static gboolean
ephy_tree_model_node_iter_next (GtkTreeModel *tree_model,
- GtkTreeIter *iter)
+ GtkTreeIter *iter)
{
- EphyTreeModelNode *model = EPHY_TREE_MODEL_NODE (tree_model);
- EphyNode *node;
+ EphyTreeModelNode *model = EPHY_TREE_MODEL_NODE (tree_model);
+ EphyNode *node;
- g_return_val_if_fail (iter != NULL, FALSE);
- g_return_val_if_fail (iter->user_data != NULL, FALSE);
- g_return_val_if_fail (iter->stamp == model->stamp, FALSE);
+ g_return_val_if_fail (iter != NULL, FALSE);
+ g_return_val_if_fail (iter->user_data != NULL, FALSE);
+ g_return_val_if_fail (iter->stamp == model->stamp, FALSE);
- if (model->root == NULL)
- return FALSE;
+ if (model->root == NULL)
+ return FALSE;
- node = iter->user_data;
+ node = iter->user_data;
- if (node == model->root)
- return FALSE;
+ if (node == model->root)
+ return FALSE;
- iter->user_data = ephy_node_get_next_child (model->root, node);
+ iter->user_data = ephy_node_get_next_child (model->root, node);
- return (iter->user_data != NULL);
+ return (iter->user_data != NULL);
}
static gboolean
ephy_tree_model_node_iter_children (GtkTreeModel *tree_model,
- GtkTreeIter *iter,
- GtkTreeIter *parent)
+ GtkTreeIter *iter,
+ GtkTreeIter *parent)
{
- EphyTreeModelNode *model = EPHY_TREE_MODEL_NODE (tree_model);
+ EphyTreeModelNode *model = EPHY_TREE_MODEL_NODE (tree_model);
- if (model->root == NULL)
- return FALSE;
+ if (model->root == NULL)
+ return FALSE;
- if (parent != NULL)
- return FALSE;
+ if (parent != NULL)
+ return FALSE;
- iter->stamp = model->stamp;
- iter->user_data = model->root;
+ iter->stamp = model->stamp;
+ iter->user_data = model->root;
- return TRUE;
+ return TRUE;
}
static gboolean
ephy_tree_model_node_iter_has_child (GtkTreeModel *tree_model,
- GtkTreeIter *iter)
+ GtkTreeIter *iter)
{
- return FALSE;
+ return FALSE;
}
static int
ephy_tree_model_node_iter_n_children (GtkTreeModel *tree_model,
- GtkTreeIter *iter)
+ GtkTreeIter *iter)
{
- EphyTreeModelNode *model = EPHY_TREE_MODEL_NODE (tree_model);
+ EphyTreeModelNode *model = EPHY_TREE_MODEL_NODE (tree_model);
- g_return_val_if_fail (EPHY_IS_TREE_MODEL_NODE (tree_model), -1);
+ g_return_val_if_fail (EPHY_IS_TREE_MODEL_NODE (tree_model), -1);
- if (model->root == NULL)
- return 0;
+ if (model->root == NULL)
+ return 0;
- if (iter == NULL)
- return ephy_node_get_n_children (model->root);
+ if (iter == NULL)
+ return ephy_node_get_n_children (model->root);
- g_return_val_if_fail (model->stamp == iter->stamp, -1);
+ g_return_val_if_fail (model->stamp == iter->stamp, -1);
- return 0;
+ return 0;
}
static gboolean
ephy_tree_model_node_iter_nth_child (GtkTreeModel *tree_model,
- GtkTreeIter *iter,
- GtkTreeIter *parent,
- int n)
+ GtkTreeIter *iter,
+ GtkTreeIter *parent,
+ int n)
{
- EphyTreeModelNode *model = EPHY_TREE_MODEL_NODE (tree_model);
- EphyNode *node;
+ EphyTreeModelNode *model = EPHY_TREE_MODEL_NODE (tree_model);
+ EphyNode *node;
- g_return_val_if_fail (EPHY_IS_TREE_MODEL_NODE (tree_model), FALSE);
+ g_return_val_if_fail (EPHY_IS_TREE_MODEL_NODE (tree_model), FALSE);
- if (model->root == NULL)
- return FALSE;
+ if (model->root == NULL)
+ return FALSE;
- if (parent != NULL)
- return FALSE;
+ if (parent != NULL)
+ return FALSE;
- node = ephy_node_get_nth_child (model->root, n);
+ node = ephy_node_get_nth_child (model->root, n);
- if (node != NULL)
- {
- iter->stamp = model->stamp;
- iter->user_data = node;
- return TRUE;
- }
- else
- return FALSE;
+ if (node != NULL) {
+ iter->stamp = model->stamp;
+ iter->user_data = node;
+ return TRUE;
+ } else
+ return FALSE;
}
static gboolean
ephy_tree_model_node_iter_parent (GtkTreeModel *tree_model,
- GtkTreeIter *iter,
- GtkTreeIter *child)
+ GtkTreeIter *iter,
+ GtkTreeIter *child)
{
- return FALSE;
+ return FALSE;
}
/**
@@ -601,9 +586,9 @@ ephy_tree_model_node_iter_parent (GtkTreeModel *tree_model,
**/
EphyNode *
ephy_tree_model_node_node_from_iter (EphyTreeModelNode *model,
- GtkTreeIter *iter)
+ GtkTreeIter *iter)
{
- return iter->user_data;
+ return iter->user_data;
}
/**
@@ -616,26 +601,26 @@ ephy_tree_model_node_node_from_iter (EphyTreeModelNode *model,
**/
void
ephy_tree_model_node_iter_from_node (EphyTreeModelNode *model,
- EphyNode *node,
- GtkTreeIter *iter)
+ EphyNode *node,
+ GtkTreeIter *iter)
{
- iter->stamp = model->stamp;
- iter->user_data = node;
+ iter->stamp = model->stamp;
+ iter->user_data = node;
}
static void
ephy_tree_model_node_tree_model_interface_init (GtkTreeModelIface *iface)
{
- iface->get_flags = ephy_tree_model_node_get_flags;
- iface->get_iter = ephy_tree_model_node_get_iter;
- iface->get_path = ephy_tree_model_node_get_path;
- iface->iter_next = ephy_tree_model_node_iter_next;
- iface->iter_children = ephy_tree_model_node_iter_children;
- iface->iter_has_child = ephy_tree_model_node_iter_has_child;
- iface->iter_n_children = ephy_tree_model_node_iter_n_children;
- iface->iter_nth_child = ephy_tree_model_node_iter_nth_child;
- iface->iter_parent = ephy_tree_model_node_iter_parent;
- iface->get_n_columns = ephy_tree_model_node_get_n_columns;
- iface->get_column_type = ephy_tree_model_node_get_column_type;
- iface->get_value = ephy_tree_model_node_get_value;
+ iface->get_flags = ephy_tree_model_node_get_flags;
+ iface->get_iter = ephy_tree_model_node_get_iter;
+ iface->get_path = ephy_tree_model_node_get_path;
+ iface->iter_next = ephy_tree_model_node_iter_next;
+ iface->iter_children = ephy_tree_model_node_iter_children;
+ iface->iter_has_child = ephy_tree_model_node_iter_has_child;
+ iface->iter_n_children = ephy_tree_model_node_iter_n_children;
+ iface->iter_nth_child = ephy_tree_model_node_iter_nth_child;
+ iface->iter_parent = ephy_tree_model_node_iter_parent;
+ iface->get_n_columns = ephy_tree_model_node_get_n_columns;
+ iface->get_column_type = ephy_tree_model_node_get_column_type;
+ iface->get_value = ephy_tree_model_node_get_value;
}
diff --git a/lib/widgets/ephy-tree-model-sort.c b/lib/widgets/ephy-tree-model-sort.c
index 82d0441dc..96037f45c 100644
--- a/lib/widgets/ephy-tree-model-sort.c
+++ b/lib/widgets/ephy-tree-model-sort.c
@@ -37,19 +37,18 @@
static void ephy_tree_model_sort_finalize (GObject *object);
static void ephy_tree_model_sort_multi_drag_source_interface_init (EggTreeMultiDragSourceIface *iface);
static gboolean ephy_tree_model_sort_multi_row_draggable (EggTreeMultiDragSource *drag_source,
- GList *path_list);
+ GList *path_list);
static gboolean ephy_tree_model_sort_multi_drag_data_get (EggTreeMultiDragSource *drag_source,
- GList *path_list,
- GtkSelectionData *selection_data);
+ GList *path_list,
+ GtkSelectionData *selection_data);
static gboolean ephy_tree_model_sort_multi_drag_data_delete (EggTreeMultiDragSource *drag_source,
- GList *path_list);
+ GList *path_list);
-struct _EphyTreeModelSort
-{
- GtkTreeModelSort parent_instance;
- char *str_list;
- int base_drag_column_id;
- int extra_drag_column_id;
+struct _EphyTreeModelSort {
+ GtkTreeModelSort parent_instance;
+ char *str_list;
+ int base_drag_column_id;
+ int extra_drag_column_id;
};
G_DEFINE_TYPE_WITH_CODE (EphyTreeModelSort, ephy_tree_model_sort, GTK_TYPE_TREE_MODEL_SORT,
@@ -59,26 +58,26 @@ G_DEFINE_TYPE_WITH_CODE (EphyTreeModelSort, ephy_tree_model_sort, GTK_TYPE_TREE_
static void
ephy_tree_model_sort_class_init (EphyTreeModelSortClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = ephy_tree_model_sort_finalize;
+ object_class->finalize = ephy_tree_model_sort_finalize;
}
static void
ephy_tree_model_sort_init (EphyTreeModelSort *ma)
{
- ma->base_drag_column_id = -1;
- ma->extra_drag_column_id = -1;
+ ma->base_drag_column_id = -1;
+ ma->extra_drag_column_id = -1;
}
static void
ephy_tree_model_sort_finalize (GObject *object)
{
- EphyTreeModelSort *model = EPHY_TREE_MODEL_SORT (object);
+ EphyTreeModelSort *model = EPHY_TREE_MODEL_SORT (object);
- g_free (model->str_list);
+ g_free (model->str_list);
- G_OBJECT_CLASS (ephy_tree_model_sort_parent_class)->finalize (object);
+ G_OBJECT_CLASS (ephy_tree_model_sort_parent_class)->finalize (object);
}
/**
@@ -89,32 +88,32 @@ ephy_tree_model_sort_finalize (GObject *object)
*
* Returns: a new #EphyTreeModelSort, as a #GtkWidget
**/
-GtkTreeModel*
+GtkTreeModel *
ephy_tree_model_sort_new (GtkTreeModel *child_model)
{
- GtkTreeModel *model;
+ GtkTreeModel *model;
- g_return_val_if_fail (child_model != NULL, NULL);
+ g_return_val_if_fail (child_model != NULL, NULL);
- model = GTK_TREE_MODEL (g_object_new (EPHY_TYPE_TREE_MODEL_SORT,
- "model", child_model,
- NULL));
+ model = GTK_TREE_MODEL (g_object_new (EPHY_TYPE_TREE_MODEL_SORT,
+ "model", child_model,
+ NULL));
- return model;
+ return model;
}
static void
ephy_tree_model_sort_multi_drag_source_interface_init (EggTreeMultiDragSourceIface *iface)
{
- iface->row_draggable = ephy_tree_model_sort_multi_row_draggable;
- iface->drag_data_get = ephy_tree_model_sort_multi_drag_data_get;
- iface->drag_data_delete = ephy_tree_model_sort_multi_drag_data_delete;
+ iface->row_draggable = ephy_tree_model_sort_multi_row_draggable;
+ iface->drag_data_get = ephy_tree_model_sort_multi_drag_data_get;
+ iface->drag_data_delete = ephy_tree_model_sort_multi_drag_data_delete;
}
static gboolean
ephy_tree_model_sort_multi_row_draggable (EggTreeMultiDragSource *drag_source, GList *path_list)
{
- return (EPHY_TREE_MODEL_SORT (drag_source)->base_drag_column_id >= 0);
+ return (EPHY_TREE_MODEL_SORT (drag_source)->base_drag_column_id >= 0);
}
/**
@@ -126,9 +125,9 @@ ephy_tree_model_sort_multi_row_draggable (EggTreeMultiDragSource *drag_source, G
**/
void
ephy_tree_model_sort_set_base_drag_column_id (EphyTreeModelSort *ms,
- int id)
+ int id)
{
- ms->base_drag_column_id = id;
+ ms->base_drag_column_id = id;
}
/**
@@ -140,76 +139,75 @@ ephy_tree_model_sort_set_base_drag_column_id (EphyTreeModelSort *ms,
**/
void
ephy_tree_model_sort_set_extra_drag_column_id (EphyTreeModelSort *ms,
- int id)
+ int id)
{
- ms->extra_drag_column_id = id;
+ ms->extra_drag_column_id = id;
}
static gboolean
ephy_tree_model_sort_multi_drag_data_delete (EggTreeMultiDragSource *drag_source,
- GList *path_list)
+ GList *path_list)
{
- return TRUE;
+ return TRUE;
}
static void
each_property_get_data_binder (EphyDragEachSelectedItemDataGet iteratee,
- gpointer iterator_context, gpointer data)
+ gpointer iterator_context, gpointer data)
{
- gpointer *context = (gpointer *) iterator_context;
- GList *path_list = (GList *) (context[0]);
- GList *i;
- EphyTreeModelSort *model = EPHY_TREE_MODEL_SORT (context[1]);
- GValue base_value = {0, }, extra_value = {0, };
-
- for (i = path_list; i != NULL; i = i->next)
- {
- GtkTreeIter iter;
- GtkTreePath *path = NULL;
- const char *base_data, *extra_data;
-
- path = gtk_tree_row_reference_get_path (i->data);
- gtk_tree_model_get_iter (GTK_TREE_MODEL (model), &iter, path);
-
- gtk_tree_model_get_value (GTK_TREE_MODEL (model), &iter,
- model->base_drag_column_id,
- &base_value);
- base_data = g_value_get_string (&base_value);
-
- if (model->extra_drag_column_id >= 0) {
- gtk_tree_model_get_value (GTK_TREE_MODEL (model), &iter,
- model->extra_drag_column_id,
- &extra_value);
- extra_data = g_value_get_string (&extra_value);
- } else
- extra_data = NULL;
-
- g_return_if_fail (base_data != NULL);
-
- LOG ("Data get %s (%s)", base_data, extra_data);
-
- iteratee (base_data, extra_data, data);
-
- gtk_tree_path_free (path);
- g_value_unset (&base_value);
-
- if (model->extra_drag_column_id >= 0)
- g_value_unset (&extra_value);
- }
+ gpointer *context = (gpointer *)iterator_context;
+ GList *path_list = (GList *)(context[0]);
+ GList *i;
+ EphyTreeModelSort *model = EPHY_TREE_MODEL_SORT (context[1]);
+ GValue base_value = { 0, }, extra_value = { 0, };
+
+ for (i = path_list; i != NULL; i = i->next) {
+ GtkTreeIter iter;
+ GtkTreePath *path = NULL;
+ const char *base_data, *extra_data;
+
+ path = gtk_tree_row_reference_get_path (i->data);
+ gtk_tree_model_get_iter (GTK_TREE_MODEL (model), &iter, path);
+
+ gtk_tree_model_get_value (GTK_TREE_MODEL (model), &iter,
+ model->base_drag_column_id,
+ &base_value);
+ base_data = g_value_get_string (&base_value);
+
+ if (model->extra_drag_column_id >= 0) {
+ gtk_tree_model_get_value (GTK_TREE_MODEL (model), &iter,
+ model->extra_drag_column_id,
+ &extra_value);
+ extra_data = g_value_get_string (&extra_value);
+ } else
+ extra_data = NULL;
+
+ g_return_if_fail (base_data != NULL);
+
+ LOG ("Data get %s (%s)", base_data, extra_data);
+
+ iteratee (base_data, extra_data, data);
+
+ gtk_tree_path_free (path);
+ g_value_unset (&base_value);
+
+ if (model->extra_drag_column_id >= 0)
+ g_value_unset (&extra_value);
+ }
}
static gboolean
ephy_tree_model_sort_multi_drag_data_get (EggTreeMultiDragSource *drag_source,
- GList *path_list,
- GtkSelectionData *selection_data)
+ GList *path_list,
+ GtkSelectionData *selection_data)
{
- gpointer icontext[2];
+ gpointer icontext[2];
- icontext[0] = path_list;
- icontext[1] = drag_source;
+ icontext[0] = path_list;
+ icontext[1] = drag_source;
- ephy_dnd_drag_data_get (NULL, NULL, selection_data,
- 0, &icontext, each_property_get_data_binder);
+ ephy_dnd_drag_data_get (NULL, NULL, selection_data,
+ 0, &icontext, each_property_get_data_binder);
- return TRUE;
+ return TRUE;
}
diff --git a/lib/widgets/ephy-zoom-action.c b/lib/widgets/ephy-zoom-action.c
index fe1c89938..5be43842e 100644
--- a/lib/widgets/ephy-zoom-action.c
+++ b/lib/widgets/ephy-zoom-action.c
@@ -32,24 +32,21 @@
#define EPHY_ZOOM_ACTION_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_ZOOM_ACTION, EphyZoomActionPrivate))
-struct _EphyZoomActionPrivate
-{
- float zoom;
+struct _EphyZoomActionPrivate {
+ float zoom;
};
-enum
-{
- PROP_0,
- PROP_ZOOM,
- LAST_PROP
+enum {
+ PROP_0,
+ PROP_ZOOM,
+ LAST_PROP
};
static GParamSpec *obj_properties[LAST_PROP];
-enum
-{
- ZOOM_TO_LEVEL_SIGNAL,
- LAST_SIGNAL
+enum {
+ ZOOM_TO_LEVEL_SIGNAL,
+ LAST_SIGNAL
};
static guint signals[LAST_SIGNAL] = { 0 };
@@ -59,149 +56,145 @@ G_DEFINE_TYPE (EphyZoomAction, ephy_zoom_action, GTK_TYPE_ACTION)
static void
proxy_menu_activate_cb (GtkMenuItem *menu_item, EphyZoomAction *action)
{
- gint index;
- float zoom;
+ gint index;
+ float zoom;
- /* menu item was toggled OFF */
- if (!gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (menu_item))) return;
+ /* menu item was toggled OFF */
+ if (!gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (menu_item))) return;
- index = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (menu_item), "zoom-level"));
- zoom = zoom_levels[index].level;
+ index = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (menu_item), "zoom-level"));
+ zoom = zoom_levels[index].level;
- if (zoom != action->priv->zoom)
- {
- g_signal_emit (action, signals[ZOOM_TO_LEVEL_SIGNAL], 0, zoom);
- }
+ if (zoom != action->priv->zoom) {
+ g_signal_emit (action, signals[ZOOM_TO_LEVEL_SIGNAL], 0, zoom);
+ }
}
static GtkWidget *
create_menu_item (GtkAction *action)
{
- EphyZoomActionPrivate *p = EPHY_ZOOM_ACTION (action)->priv;
- GtkWidget *menu, *menu_item;
- GSList *group = NULL;
- guint i;
+ EphyZoomActionPrivate *p = EPHY_ZOOM_ACTION (action)->priv;
+ GtkWidget *menu, *menu_item;
+ GSList *group = NULL;
+ guint i;
- menu = gtk_menu_new ();
+ menu = gtk_menu_new ();
- for (i = 0; i < n_zoom_levels; i++)
- {
- menu_item = gtk_radio_menu_item_new_with_label (group, _(zoom_levels[i].name));
- group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (menu_item));
+ for (i = 0; i < n_zoom_levels; i++) {
+ menu_item = gtk_radio_menu_item_new_with_label (group, _(zoom_levels[i].name));
+ group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (menu_item));
- gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_item),
- p->zoom == zoom_levels[i].level);
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_item),
+ p->zoom == zoom_levels[i].level);
- gtk_widget_show (menu_item);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
+ gtk_widget_show (menu_item);
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
- g_object_set_data (G_OBJECT (menu_item), "zoom-level", GINT_TO_POINTER (i));
- g_signal_connect_object (G_OBJECT (menu_item), "activate",
- G_CALLBACK (proxy_menu_activate_cb), action, 0);
- }
+ g_object_set_data (G_OBJECT (menu_item), "zoom-level", GINT_TO_POINTER (i));
+ g_signal_connect_object (G_OBJECT (menu_item), "activate",
+ G_CALLBACK (proxy_menu_activate_cb), action, 0);
+ }
- gtk_widget_show (menu);
+ gtk_widget_show (menu);
- menu_item = GTK_ACTION_CLASS (ephy_zoom_action_parent_class)->create_menu_item (action);
+ menu_item = GTK_ACTION_CLASS (ephy_zoom_action_parent_class)->create_menu_item (action);
- gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_item), menu);
+ gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_item), menu);
- gtk_widget_show (menu_item);
+ gtk_widget_show (menu_item);
- return menu_item;
+ return menu_item;
}
static void
-ephy_zoom_action_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+ephy_zoom_action_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
- EphyZoomAction *action;
-
- action = EPHY_ZOOM_ACTION (object);
-
- switch (prop_id)
- {
- case PROP_ZOOM:
- action->priv->zoom = g_value_get_float (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- }
+ EphyZoomAction *action;
+
+ action = EPHY_ZOOM_ACTION (object);
+
+ switch (prop_id) {
+ case PROP_ZOOM:
+ action->priv->zoom = g_value_get_float (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
}
static void
-ephy_zoom_action_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+ephy_zoom_action_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
{
- EphyZoomAction *action;
-
- action = EPHY_ZOOM_ACTION (object);
-
- switch (prop_id)
- {
- case PROP_ZOOM:
- g_value_set_float (value, action->priv->zoom);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- }
+ EphyZoomAction *action;
+
+ action = EPHY_ZOOM_ACTION (object);
+
+ switch (prop_id) {
+ case PROP_ZOOM:
+ g_value_set_float (value, action->priv->zoom);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
}
static void
ephy_zoom_action_class_init (EphyZoomActionClass *class)
{
- GObjectClass *object_class = G_OBJECT_CLASS (class);
- GtkActionClass *action_class = GTK_ACTION_CLASS (class);
-
- object_class->set_property = ephy_zoom_action_set_property;
- object_class->get_property = ephy_zoom_action_get_property;
-
- action_class->create_menu_item = create_menu_item;
-
- /**
- * EphyZoomAction:zoom:
- *
- * The current value of #EphyZoomAction, as a float.
- */
- obj_properties[PROP_ZOOM] =
- g_param_spec_float ("zoom", NULL, NULL,
- ZOOM_MINIMAL,
- ZOOM_MAXIMAL,
- 1.0,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
-
- g_object_class_install_properties (object_class, LAST_PROP, obj_properties);
-
- /**
- * EphyZoomAction::zoom-to-level:
- * @action: the object on which the signal is emitted
- * @level: new zoom level
- *
- * Emitted when the user changes the value of the #EphyZoomAction.
- */
- signals[ZOOM_TO_LEVEL_SIGNAL] =
- g_signal_new ("zoom-to-level",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (EphyZoomActionClass, zoom_to_level),
- NULL, NULL, NULL,
- G_TYPE_NONE,
- 1,
- G_TYPE_FLOAT);
-
- g_type_class_add_private (object_class, sizeof (EphyZoomActionPrivate));
+ GObjectClass *object_class = G_OBJECT_CLASS (class);
+ GtkActionClass *action_class = GTK_ACTION_CLASS (class);
+
+ object_class->set_property = ephy_zoom_action_set_property;
+ object_class->get_property = ephy_zoom_action_get_property;
+
+ action_class->create_menu_item = create_menu_item;
+
+ /**
+ * EphyZoomAction:zoom:
+ *
+ * The current value of #EphyZoomAction, as a float.
+ */
+ obj_properties[PROP_ZOOM] =
+ g_param_spec_float ("zoom", NULL, NULL,
+ ZOOM_MINIMAL,
+ ZOOM_MAXIMAL,
+ 1.0,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+
+ g_object_class_install_properties (object_class, LAST_PROP, obj_properties);
+
+ /**
+ * EphyZoomAction::zoom-to-level:
+ * @action: the object on which the signal is emitted
+ * @level: new zoom level
+ *
+ * Emitted when the user changes the value of the #EphyZoomAction.
+ */
+ signals[ZOOM_TO_LEVEL_SIGNAL] =
+ g_signal_new ("zoom-to-level",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (EphyZoomActionClass, zoom_to_level),
+ NULL, NULL, NULL,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_FLOAT);
+
+ g_type_class_add_private (object_class, sizeof (EphyZoomActionPrivate));
}
static void
ephy_zoom_action_init (EphyZoomAction *action)
{
- action->priv = EPHY_ZOOM_ACTION_GET_PRIVATE (action);
+ action->priv = EPHY_ZOOM_ACTION_GET_PRIVATE (action);
- action->priv->zoom = 1.0;
+ action->priv->zoom = 1.0;
}
/**
@@ -214,12 +207,12 @@ ephy_zoom_action_init (EphyZoomAction *action)
void
ephy_zoom_action_set_zoom_level (EphyZoomAction *action, float zoom)
{
- g_return_if_fail (EPHY_IS_ZOOM_ACTION (action));
-
- if (zoom < ZOOM_MINIMAL || zoom > ZOOM_MAXIMAL) return;
+ g_return_if_fail (EPHY_IS_ZOOM_ACTION (action));
- action->priv->zoom = zoom;
- g_object_notify_by_pspec (G_OBJECT (action), obj_properties[PROP_ZOOM]);
+ if (zoom < ZOOM_MINIMAL || zoom > ZOOM_MAXIMAL) return;
+
+ action->priv->zoom = zoom;
+ g_object_notify_by_pspec (G_OBJECT (action), obj_properties[PROP_ZOOM]);
}
/**
@@ -233,7 +226,7 @@ ephy_zoom_action_set_zoom_level (EphyZoomAction *action, float zoom)
float
ephy_zoom_action_get_zoom_level (EphyZoomAction *action)
{
- g_return_val_if_fail (EPHY_IS_ZOOM_ACTION (action), 1.0);
-
- return action->priv->zoom;
+ g_return_val_if_fail (EPHY_IS_ZOOM_ACTION (action), 1.0);
+
+ return action->priv->zoom;
}
diff --git a/lib/widgets/nautilus-floating-bar.c b/lib/widgets/nautilus-floating-bar.c
index 52219b95f..586dcd069 100644
--- a/lib/widgets/nautilus-floating-bar.c
+++ b/lib/widgets/nautilus-floating-bar.c
@@ -28,27 +28,27 @@
#include "nautilus-floating-bar.h"
struct _NautilusFloatingBarDetails {
- gchar *primary_label;
- gchar *details_label;
-
- GtkWidget *primary_label_widget;
- GtkWidget *details_label_widget;
- GtkWidget *spinner;
- gboolean show_spinner;
- gboolean is_interactive;
- guint hover_timeout_id;
+ gchar *primary_label;
+ gchar *details_label;
+
+ GtkWidget *primary_label_widget;
+ GtkWidget *details_label_widget;
+ GtkWidget *spinner;
+ gboolean show_spinner;
+ gboolean is_interactive;
+ guint hover_timeout_id;
};
enum {
- PROP_PRIMARY_LABEL = 1,
- PROP_DETAILS_LABEL,
- PROP_SHOW_SPINNER,
- NUM_PROPERTIES
+ PROP_PRIMARY_LABEL = 1,
+ PROP_DETAILS_LABEL,
+ PROP_SHOW_SPINNER,
+ NUM_PROPERTIES
};
enum {
- ACTION,
- NUM_SIGNALS
+ ACTION,
+ NUM_SIGNALS
};
static GParamSpec *properties[NUM_PROPERTIES] = { NULL, };
@@ -58,458 +58,458 @@ G_DEFINE_TYPE (NautilusFloatingBar, nautilus_floating_bar,
GTK_TYPE_BOX);
static void
-action_button_clicked_cb (GtkButton *button,
- NautilusFloatingBar *self)
+action_button_clicked_cb (GtkButton *button,
+ NautilusFloatingBar *self)
{
- gint action_id;
+ gint action_id;
- action_id = GPOINTER_TO_INT
- (g_object_get_data (G_OBJECT (button), "action-id"));
-
- g_signal_emit (self, signals[ACTION], 0, action_id);
+ action_id = GPOINTER_TO_INT
+ (g_object_get_data (G_OBJECT (button), "action-id"));
+
+ g_signal_emit (self, signals[ACTION], 0, action_id);
}
static void
nautilus_floating_bar_finalize (GObject *obj)
{
- NautilusFloatingBar *self = NAUTILUS_FLOATING_BAR (obj);
+ NautilusFloatingBar *self = NAUTILUS_FLOATING_BAR (obj);
- g_free (self->priv->primary_label);
- g_free (self->priv->details_label);
+ g_free (self->priv->primary_label);
+ g_free (self->priv->details_label);
- G_OBJECT_CLASS (nautilus_floating_bar_parent_class)->finalize (obj);
+ G_OBJECT_CLASS (nautilus_floating_bar_parent_class)->finalize (obj);
}
static void
-nautilus_floating_bar_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
+nautilus_floating_bar_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
{
- NautilusFloatingBar *self = NAUTILUS_FLOATING_BAR (object);
-
- switch (property_id) {
- case PROP_PRIMARY_LABEL:
- g_value_set_string (value, self->priv->primary_label);
- break;
- case PROP_DETAILS_LABEL:
- g_value_set_string (value, self->priv->details_label);
- break;
- case PROP_SHOW_SPINNER:
- g_value_set_boolean (value, self->priv->show_spinner);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- break;
- }
+ NautilusFloatingBar *self = NAUTILUS_FLOATING_BAR (object);
+
+ switch (property_id) {
+ case PROP_PRIMARY_LABEL:
+ g_value_set_string (value, self->priv->primary_label);
+ break;
+ case PROP_DETAILS_LABEL:
+ g_value_set_string (value, self->priv->details_label);
+ break;
+ case PROP_SHOW_SPINNER:
+ g_value_set_boolean (value, self->priv->show_spinner);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
}
static void
-nautilus_floating_bar_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
+nautilus_floating_bar_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
- NautilusFloatingBar *self = NAUTILUS_FLOATING_BAR (object);
-
- switch (property_id) {
- case PROP_PRIMARY_LABEL:
- nautilus_floating_bar_set_primary_label (self, g_value_get_string (value));
- break;
- case PROP_DETAILS_LABEL:
- nautilus_floating_bar_set_details_label (self, g_value_get_string (value));
- break;
- case PROP_SHOW_SPINNER:
- nautilus_floating_bar_set_show_spinner (self, g_value_get_boolean (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- break;
- }
+ NautilusFloatingBar *self = NAUTILUS_FLOATING_BAR (object);
+
+ switch (property_id) {
+ case PROP_PRIMARY_LABEL:
+ nautilus_floating_bar_set_primary_label (self, g_value_get_string (value));
+ break;
+ case PROP_DETAILS_LABEL:
+ nautilus_floating_bar_set_details_label (self, g_value_get_string (value));
+ break;
+ case PROP_SHOW_SPINNER:
+ nautilus_floating_bar_set_show_spinner (self, g_value_get_boolean (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
}
static void
update_labels (NautilusFloatingBar *self)
{
- gboolean primary_visible, details_visible;
+ gboolean primary_visible, details_visible;
- primary_visible = (self->priv->primary_label != NULL) &&
- (strlen (self->priv->primary_label) > 0);
- details_visible = (self->priv->details_label != NULL) &&
- (strlen (self->priv->details_label) > 0);
+ primary_visible = (self->priv->primary_label != NULL) &&
+ (strlen (self->priv->primary_label) > 0);
+ details_visible = (self->priv->details_label != NULL) &&
+ (strlen (self->priv->details_label) > 0);
- gtk_label_set_text (GTK_LABEL (self->priv->primary_label_widget),
- self->priv->primary_label);
- gtk_widget_set_visible (self->priv->primary_label_widget, primary_visible);
+ gtk_label_set_text (GTK_LABEL (self->priv->primary_label_widget),
+ self->priv->primary_label);
+ gtk_widget_set_visible (self->priv->primary_label_widget, primary_visible);
- gtk_label_set_text (GTK_LABEL (self->priv->details_label_widget),
- self->priv->details_label);
- gtk_widget_set_visible (self->priv->details_label_widget, details_visible);
+ gtk_label_set_text (GTK_LABEL (self->priv->details_label_widget),
+ self->priv->details_label);
+ gtk_widget_set_visible (self->priv->details_label_widget, details_visible);
}
static void
nautilus_floating_bar_show (GtkWidget *widget)
{
- NautilusFloatingBar *self = NAUTILUS_FLOATING_BAR (widget);
+ NautilusFloatingBar *self = NAUTILUS_FLOATING_BAR (widget);
- /* Epiphany: never show the bar on top of the web view. */
- if (gtk_widget_get_valign (widget) == GTK_ALIGN_START)
- return;
+ /* Epiphany: never show the bar on top of the web view. */
+ if (gtk_widget_get_valign (widget) == GTK_ALIGN_START)
+ return;
- GTK_WIDGET_CLASS (nautilus_floating_bar_parent_class)->show (widget);
+ GTK_WIDGET_CLASS (nautilus_floating_bar_parent_class)->show (widget);
- if (self->priv->show_spinner) {
- gtk_spinner_start (GTK_SPINNER (self->priv->spinner));
- }
+ if (self->priv->show_spinner) {
+ gtk_spinner_start (GTK_SPINNER (self->priv->spinner));
+ }
}
static void
nautilus_floating_bar_hide (GtkWidget *widget)
{
- NautilusFloatingBar *self = NAUTILUS_FLOATING_BAR (widget);
+ NautilusFloatingBar *self = NAUTILUS_FLOATING_BAR (widget);
- GTK_WIDGET_CLASS (nautilus_floating_bar_parent_class)->hide (widget);
+ GTK_WIDGET_CLASS (nautilus_floating_bar_parent_class)->hide (widget);
- gtk_spinner_stop (GTK_SPINNER (self->priv->spinner));
+ gtk_spinner_stop (GTK_SPINNER (self->priv->spinner));
}
typedef struct {
- GtkWidget *overlay;
- GtkWidget *floating_bar;
- GdkDevice *device;
- gint y_down_limit;
- gint y_upper_limit;
- gboolean first_time;
+ GtkWidget *overlay;
+ GtkWidget *floating_bar;
+ GdkDevice *device;
+ gint y_down_limit;
+ gint y_upper_limit;
+ gboolean first_time;
} CheckPointerData;
static gboolean
check_pointer_timeout (gpointer user_data)
{
- CheckPointerData *data = user_data;
- gint pointer_y = -1;
-
- gdk_window_get_device_position (gtk_widget_get_window (data->overlay), data->device,
- NULL, &pointer_y, NULL);
-
- if (pointer_y == -1 || pointer_y < data->y_down_limit || pointer_y > data->y_upper_limit) {
- if (!data->first_time) {
- gtk_widget_set_valign (data->floating_bar, GTK_ALIGN_END);
- nautilus_floating_bar_show (data->floating_bar);
- }
- NAUTILUS_FLOATING_BAR (data->floating_bar)->priv->hover_timeout_id = 0;
- return G_SOURCE_REMOVE;
- }
-
- if (data->first_time) {
- // Hide floating bar at top position of widget
- nautilus_floating_bar_hide (data->floating_bar);
- gtk_widget_set_valign (data->floating_bar, GTK_ALIGN_START);
- gtk_widget_queue_resize (data->floating_bar);
- }
-
- data->first_time = FALSE;
- return G_SOURCE_CONTINUE;
+ CheckPointerData *data = user_data;
+ gint pointer_y = -1;
+
+ gdk_window_get_device_position (gtk_widget_get_window (data->overlay), data->device,
+ NULL, &pointer_y, NULL);
+
+ if (pointer_y == -1 || pointer_y < data->y_down_limit || pointer_y > data->y_upper_limit) {
+ if (!data->first_time) {
+ gtk_widget_set_valign (data->floating_bar, GTK_ALIGN_END);
+ nautilus_floating_bar_show (data->floating_bar);
+ }
+ NAUTILUS_FLOATING_BAR (data->floating_bar)->priv->hover_timeout_id = 0;
+ return G_SOURCE_REMOVE;
+ }
+
+ if (data->first_time) {
+ /* Hide floating bar at top position of widget */
+ nautilus_floating_bar_hide (data->floating_bar);
+ gtk_widget_set_valign (data->floating_bar, GTK_ALIGN_START);
+ gtk_widget_queue_resize (data->floating_bar);
+ }
+
+ data->first_time = FALSE;
+ return G_SOURCE_CONTINUE;
}
static gboolean
overlay_enter_notify_cb (GtkWidget *parent,
- GdkEventCrossing *event,
- gpointer user_data)
+ GdkEventCrossing *event,
+ gpointer user_data)
{
- GtkWidget *widget = user_data;
- CheckPointerData *data;
- GtkAllocation alloc_parent;
- gint y_pos;
-
- NautilusFloatingBar *self = NAUTILUS_FLOATING_BAR (widget);
-
- if (self->priv->hover_timeout_id != 0) {
- g_source_remove (self->priv->hover_timeout_id);
- self->priv->hover_timeout_id = 0;
- }
-
- if (event->window != gtk_widget_get_window (widget)) {
- return GDK_EVENT_PROPAGATE;
- }
-
- if (NAUTILUS_FLOATING_BAR (widget)->priv->is_interactive) {
- return GDK_EVENT_PROPAGATE;
- }
-
- gtk_widget_get_allocation (parent, &alloc_parent);
- gdk_window_get_position (gtk_widget_get_window (widget), NULL, &y_pos);
-
- data = g_new (CheckPointerData, 1);
- data->overlay = parent;
- data->floating_bar = widget;
- data->device = gdk_event_get_device ((GdkEvent *) event);
- data->y_down_limit = y_pos;
- data->y_upper_limit = alloc_parent.height;
- data->first_time = TRUE;
-
- self->priv->hover_timeout_id = g_timeout_add_full (G_PRIORITY_DEFAULT, 250,
- check_pointer_timeout, data,
- g_free);
- g_source_set_name_by_id (self->priv->hover_timeout_id, "[nautilus-floating-bar] overlay_enter_notify_cb");
-
- return GDK_EVENT_STOP;
+ GtkWidget *widget = user_data;
+ CheckPointerData *data;
+ GtkAllocation alloc_parent;
+ gint y_pos;
+
+ NautilusFloatingBar *self = NAUTILUS_FLOATING_BAR (widget);
+
+ if (self->priv->hover_timeout_id != 0) {
+ g_source_remove (self->priv->hover_timeout_id);
+ self->priv->hover_timeout_id = 0;
+ }
+
+ if (event->window != gtk_widget_get_window (widget)) {
+ return GDK_EVENT_PROPAGATE;
+ }
+
+ if (NAUTILUS_FLOATING_BAR (widget)->priv->is_interactive) {
+ return GDK_EVENT_PROPAGATE;
+ }
+
+ gtk_widget_get_allocation (parent, &alloc_parent);
+ gdk_window_get_position (gtk_widget_get_window (widget), NULL, &y_pos);
+
+ data = g_new (CheckPointerData, 1);
+ data->overlay = parent;
+ data->floating_bar = widget;
+ data->device = gdk_event_get_device ((GdkEvent *)event);
+ data->y_down_limit = y_pos;
+ data->y_upper_limit = alloc_parent.height;
+ data->first_time = TRUE;
+
+ self->priv->hover_timeout_id = g_timeout_add_full (G_PRIORITY_DEFAULT, 250,
+ check_pointer_timeout, data,
+ g_free);
+ g_source_set_name_by_id (self->priv->hover_timeout_id, "[nautilus-floating-bar] overlay_enter_notify_cb");
+
+ return GDK_EVENT_STOP;
}
static void
nautilus_floating_bar_parent_set (GtkWidget *widget,
- GtkWidget *old_parent)
+ GtkWidget *old_parent)
{
- GtkWidget *parent;
+ GtkWidget *parent;
- parent = gtk_widget_get_parent (widget);
+ parent = gtk_widget_get_parent (widget);
- if (old_parent != NULL) {
- g_signal_handlers_disconnect_by_func (old_parent,
- overlay_enter_notify_cb, widget);
- }
+ if (old_parent != NULL) {
+ g_signal_handlers_disconnect_by_func (old_parent,
+ overlay_enter_notify_cb, widget);
+ }
- if (parent != NULL) {
- g_signal_connect (parent, "enter-notify-event",
- G_CALLBACK (overlay_enter_notify_cb), widget);
- }
+ if (parent != NULL) {
+ g_signal_connect (parent, "enter-notify-event",
+ G_CALLBACK (overlay_enter_notify_cb), widget);
+ }
}
static gboolean
nautilus_floating_bar_draw (GtkWidget *widget,
- cairo_t *cr)
+ cairo_t *cr)
{
- GtkStyleContext *context;
+ GtkStyleContext *context;
- context = gtk_widget_get_style_context (widget);
+ context = gtk_widget_get_style_context (widget);
- gtk_style_context_save (context);
- gtk_style_context_set_state (context, gtk_widget_get_state_flags (widget));
+ gtk_style_context_save (context);
+ gtk_style_context_set_state (context, gtk_widget_get_state_flags (widget));
- gtk_render_background (context, cr, 0, 0,
- gtk_widget_get_allocated_width (widget),
- gtk_widget_get_allocated_height (widget));
+ gtk_render_background (context, cr, 0, 0,
+ gtk_widget_get_allocated_width (widget),
+ gtk_widget_get_allocated_height (widget));
- gtk_render_frame (context, cr, 0, 0,
- gtk_widget_get_allocated_width (widget),
- gtk_widget_get_allocated_height (widget));
+ gtk_render_frame (context, cr, 0, 0,
+ gtk_widget_get_allocated_width (widget),
+ gtk_widget_get_allocated_height (widget));
- gtk_style_context_restore (context);
+ gtk_style_context_restore (context);
- return GTK_WIDGET_CLASS (nautilus_floating_bar_parent_class)->draw (widget, cr);;
+ return GTK_WIDGET_CLASS (nautilus_floating_bar_parent_class)->draw (widget, cr);;
}
static void
nautilus_floating_bar_constructed (GObject *obj)
{
- NautilusFloatingBar *self = NAUTILUS_FLOATING_BAR (obj);
- GtkWidget *w, *box, *labels_box;
-
- G_OBJECT_CLASS (nautilus_floating_bar_parent_class)->constructed (obj);
-
- box = GTK_WIDGET (obj);
-
- w = gtk_spinner_new ();
- gtk_box_pack_start (GTK_BOX (box), w, FALSE, FALSE, 0);
- gtk_widget_set_visible (w, self->priv->show_spinner);
- self->priv->spinner = w;
-
- gtk_widget_set_size_request (w, 16, 16);
- gtk_widget_set_margin_left (w, 8);
-
- labels_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
- gtk_box_pack_start (GTK_BOX (box), labels_box, TRUE, TRUE, 0);
- g_object_set (labels_box,
- "margin-top", 2,
- "margin-bottom", 2,
- "margin-start", 12,
- "margin-end", 12,
- NULL);
- gtk_widget_show (labels_box);
-
- w = gtk_label_new (NULL);
- gtk_label_set_ellipsize (GTK_LABEL (w), PANGO_ELLIPSIZE_MIDDLE);
- gtk_label_set_single_line_mode (GTK_LABEL (w), TRUE);
- gtk_container_add (GTK_CONTAINER (labels_box), w);
- self->priv->primary_label_widget = w;
- gtk_widget_show (w);
-
- w = gtk_label_new (NULL);
- gtk_label_set_single_line_mode (GTK_LABEL (w), TRUE);
- gtk_container_add (GTK_CONTAINER (labels_box), w);
- self->priv->details_label_widget = w;
- gtk_widget_show (w);
+ NautilusFloatingBar *self = NAUTILUS_FLOATING_BAR (obj);
+ GtkWidget *w, *box, *labels_box;
+
+ G_OBJECT_CLASS (nautilus_floating_bar_parent_class)->constructed (obj);
+
+ box = GTK_WIDGET (obj);
+
+ w = gtk_spinner_new ();
+ gtk_box_pack_start (GTK_BOX (box), w, FALSE, FALSE, 0);
+ gtk_widget_set_visible (w, self->priv->show_spinner);
+ self->priv->spinner = w;
+
+ gtk_widget_set_size_request (w, 16, 16);
+ gtk_widget_set_margin_left (w, 8);
+
+ labels_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
+ gtk_box_pack_start (GTK_BOX (box), labels_box, TRUE, TRUE, 0);
+ g_object_set (labels_box,
+ "margin-top", 2,
+ "margin-bottom", 2,
+ "margin-start", 12,
+ "margin-end", 12,
+ NULL);
+ gtk_widget_show (labels_box);
+
+ w = gtk_label_new (NULL);
+ gtk_label_set_ellipsize (GTK_LABEL (w), PANGO_ELLIPSIZE_MIDDLE);
+ gtk_label_set_single_line_mode (GTK_LABEL (w), TRUE);
+ gtk_container_add (GTK_CONTAINER (labels_box), w);
+ self->priv->primary_label_widget = w;
+ gtk_widget_show (w);
+
+ w = gtk_label_new (NULL);
+ gtk_label_set_single_line_mode (GTK_LABEL (w), TRUE);
+ gtk_container_add (GTK_CONTAINER (labels_box), w);
+ self->priv->details_label_widget = w;
+ gtk_widget_show (w);
}
static void
nautilus_floating_bar_init (NautilusFloatingBar *self)
{
- GtkStyleContext *context;
+ GtkStyleContext *context;
- self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, NAUTILUS_TYPE_FLOATING_BAR,
- NautilusFloatingBarDetails);
+ self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, NAUTILUS_TYPE_FLOATING_BAR,
+ NautilusFloatingBarDetails);
- context = gtk_widget_get_style_context (GTK_WIDGET (self));
- gtk_style_context_add_class (context, "floating-bar");
+ context = gtk_widget_get_style_context (GTK_WIDGET (self));
+ gtk_style_context_add_class (context, "floating-bar");
}
static void
nautilus_floating_bar_class_init (NautilusFloatingBarClass *klass)
{
- GObjectClass *oclass = G_OBJECT_CLASS (klass);
- GtkWidgetClass *wclass = GTK_WIDGET_CLASS (klass);
-
- oclass->constructed = nautilus_floating_bar_constructed;
- oclass->set_property = nautilus_floating_bar_set_property;
- oclass->get_property = nautilus_floating_bar_get_property;
- oclass->finalize = nautilus_floating_bar_finalize;
-
- wclass->draw = nautilus_floating_bar_draw;
- wclass->show = nautilus_floating_bar_show;
- wclass->hide = nautilus_floating_bar_hide;
- wclass->parent_set = nautilus_floating_bar_parent_set;
-
- properties[PROP_PRIMARY_LABEL] =
- g_param_spec_string ("primary-label",
- "Bar's primary label",
- "Primary label displayed by the bar",
- NULL,
- G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS);
- properties[PROP_DETAILS_LABEL] =
- g_param_spec_string ("details-label",
- "Bar's details label",
- "Details label displayed by the bar",
- NULL,
- G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS);
- properties[PROP_SHOW_SPINNER] =
- g_param_spec_boolean ("show-spinner",
- "Show spinner",
- "Whether a spinner should be shown in the floating bar",
- FALSE,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
-
- signals[ACTION] =
- g_signal_new ("action",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- 0, NULL, NULL, NULL,
- G_TYPE_NONE, 1,
- G_TYPE_INT);
-
- g_type_class_add_private (klass, sizeof (NautilusFloatingBarDetails));
- g_object_class_install_properties (oclass, NUM_PROPERTIES, properties);
+ GObjectClass *oclass = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *wclass = GTK_WIDGET_CLASS (klass);
+
+ oclass->constructed = nautilus_floating_bar_constructed;
+ oclass->set_property = nautilus_floating_bar_set_property;
+ oclass->get_property = nautilus_floating_bar_get_property;
+ oclass->finalize = nautilus_floating_bar_finalize;
+
+ wclass->draw = nautilus_floating_bar_draw;
+ wclass->show = nautilus_floating_bar_show;
+ wclass->hide = nautilus_floating_bar_hide;
+ wclass->parent_set = nautilus_floating_bar_parent_set;
+
+ properties[PROP_PRIMARY_LABEL] =
+ g_param_spec_string ("primary-label",
+ "Bar's primary label",
+ "Primary label displayed by the bar",
+ NULL,
+ G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS);
+ properties[PROP_DETAILS_LABEL] =
+ g_param_spec_string ("details-label",
+ "Bar's details label",
+ "Details label displayed by the bar",
+ NULL,
+ G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS);
+ properties[PROP_SHOW_SPINNER] =
+ g_param_spec_boolean ("show-spinner",
+ "Show spinner",
+ "Whether a spinner should be shown in the floating bar",
+ FALSE,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+
+ signals[ACTION] =
+ g_signal_new ("action",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL, NULL,
+ G_TYPE_NONE, 1,
+ G_TYPE_INT);
+
+ g_type_class_add_private (klass, sizeof (NautilusFloatingBarDetails));
+ g_object_class_install_properties (oclass, NUM_PROPERTIES, properties);
}
void
nautilus_floating_bar_set_primary_label (NautilusFloatingBar *self,
- const gchar *label)
+ const gchar *label)
{
- if (g_strcmp0 (self->priv->primary_label, label) != 0) {
- g_free (self->priv->primary_label);
- self->priv->primary_label = g_strdup (label);
+ if (g_strcmp0 (self->priv->primary_label, label) != 0) {
+ g_free (self->priv->primary_label);
+ self->priv->primary_label = g_strdup (label);
- g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_PRIMARY_LABEL]);
+ g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_PRIMARY_LABEL]);
- update_labels (self);
- }
+ update_labels (self);
+ }
}
void
nautilus_floating_bar_set_details_label (NautilusFloatingBar *self,
- const gchar *label)
+ const gchar *label)
{
- if (g_strcmp0 (self->priv->details_label, label) != 0) {
- g_free (self->priv->details_label);
- self->priv->details_label = g_strdup (label);
+ if (g_strcmp0 (self->priv->details_label, label) != 0) {
+ g_free (self->priv->details_label);
+ self->priv->details_label = g_strdup (label);
- g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_DETAILS_LABEL]);
+ g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_DETAILS_LABEL]);
- update_labels (self);
- }
+ update_labels (self);
+ }
}
void
nautilus_floating_bar_set_labels (NautilusFloatingBar *self,
- const gchar *primary_label,
- const gchar *details_label)
+ const gchar *primary_label,
+ const gchar *details_label)
{
- nautilus_floating_bar_set_primary_label (self, primary_label);
- nautilus_floating_bar_set_details_label (self, details_label);
+ nautilus_floating_bar_set_primary_label (self, primary_label);
+ nautilus_floating_bar_set_details_label (self, details_label);
}
void
nautilus_floating_bar_set_show_spinner (NautilusFloatingBar *self,
- gboolean show_spinner)
+ gboolean show_spinner)
{
- if (self->priv->show_spinner != show_spinner) {
- self->priv->show_spinner = show_spinner;
- gtk_widget_set_visible (self->priv->spinner,
- show_spinner);
+ if (self->priv->show_spinner != show_spinner) {
+ self->priv->show_spinner = show_spinner;
+ gtk_widget_set_visible (self->priv->spinner,
+ show_spinner);
- g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SHOW_SPINNER]);
- }
+ g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SHOW_SPINNER]);
+ }
}
GtkWidget *
nautilus_floating_bar_new (const gchar *primary_label,
- const gchar *details_label,
- gboolean show_spinner)
+ const gchar *details_label,
+ gboolean show_spinner)
{
- return g_object_new (NAUTILUS_TYPE_FLOATING_BAR,
- "primary-label", primary_label,
- "details-label", details_label,
- "show-spinner", show_spinner,
- "orientation", GTK_ORIENTATION_HORIZONTAL,
- "spacing", 8,
- NULL);
+ return g_object_new (NAUTILUS_TYPE_FLOATING_BAR,
+ "primary-label", primary_label,
+ "details-label", details_label,
+ "show-spinner", show_spinner,
+ "orientation", GTK_ORIENTATION_HORIZONTAL,
+ "spacing", 8,
+ NULL);
}
void
nautilus_floating_bar_add_action (NautilusFloatingBar *self,
- const gchar *icon_name,
- gint action_id)
+ const gchar *icon_name,
+ gint action_id)
{
- GtkWidget *w, *button;
+ GtkWidget *w, *button;
- w = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_MENU);
- gtk_widget_show (w);
+ w = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_MENU);
+ gtk_widget_show (w);
- button = gtk_button_new ();
- gtk_button_set_image (GTK_BUTTON (button), w);
- gtk_box_pack_end (GTK_BOX (self), button, FALSE, FALSE, 0);
- gtk_widget_show (button);
+ button = gtk_button_new ();
+ gtk_button_set_image (GTK_BUTTON (button), w);
+ gtk_box_pack_end (GTK_BOX (self), button, FALSE, FALSE, 0);
+ gtk_widget_show (button);
- g_object_set_data (G_OBJECT (button), "action-id",
- GINT_TO_POINTER (action_id));
+ g_object_set_data (G_OBJECT (button), "action-id",
+ GINT_TO_POINTER (action_id));
- g_signal_connect (button, "clicked",
- G_CALLBACK (action_button_clicked_cb), self);
+ g_signal_connect (button, "clicked",
+ G_CALLBACK (action_button_clicked_cb), self);
- self->priv->is_interactive = TRUE;
+ self->priv->is_interactive = TRUE;
}
void
nautilus_floating_bar_cleanup_actions (NautilusFloatingBar *self)
{
- GtkWidget *widget;
- GList *children, *l;
- gpointer data;
+ GtkWidget *widget;
+ GList *children, *l;
+ gpointer data;
- children = gtk_container_get_children (GTK_CONTAINER (self));
- l = children;
+ children = gtk_container_get_children (GTK_CONTAINER (self));
+ l = children;
- while (l != NULL) {
- widget = l->data;
- data = g_object_get_data (G_OBJECT (widget), "action-id");
- l = l->next;
+ while (l != NULL) {
+ widget = l->data;
+ data = g_object_get_data (G_OBJECT (widget), "action-id");
+ l = l->next;
- if (data != NULL) {
- /* destroy this */
- gtk_widget_destroy (widget);
- }
- }
+ if (data != NULL) {
+ /* destroy this */
+ gtk_widget_destroy (widget);
+ }
+ }
- g_list_free (children);
+ g_list_free (children);
- self->priv->is_interactive = FALSE;
+ self->priv->is_interactive = FALSE;
}