added method for setting single click policy track for changes in the
2006-01-01 Carlos Garnacho Parro <carlosg@gnome.org> * gnomecc-canvas.[ch]: added method for setting single click policy * control-center.c: track for changes in the nautilus click_policy key to make g-c-c behave exactly like nautilus
This commit is contained in:
parent
4c5123ec29
commit
821ca6fcf2
4 changed files with 94 additions and 20 deletions
|
@ -1,3 +1,9 @@
|
|||
2006-01-01 Carlos Garnacho Parro <carlosg@gnome.org>
|
||||
|
||||
* gnomecc-canvas.[ch]: added method for setting single click policy
|
||||
* control-center.c: track for changes in the nautilus click_policy key
|
||||
to make g-c-c behave exactly like nautilus
|
||||
|
||||
2005-11-14 Kjartan Maraas <kmaraas@gnome.org>
|
||||
|
||||
* control-center-categories.c: (populate_category):
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
#include <libgnomeui/libgnomeui.h>
|
||||
#include "gnomecc-canvas.h"
|
||||
|
||||
#define SINGLE_CLICK_POLICY_KEY "/apps/nautilus/preferences/click_policy"
|
||||
|
||||
static void
|
||||
gnome_cc_die (void)
|
||||
{
|
||||
|
@ -27,6 +29,55 @@ change_status (GnomeccCanvas *canvas, const gchar *status, void *data)
|
|||
gnome_appbar_set_status (bar, status);
|
||||
}
|
||||
|
||||
static void
|
||||
on_click_policy_notified (GConfClient *client,
|
||||
guint conn_id,
|
||||
GConfEntry *entry,
|
||||
GnomeccCanvas *canvas)
|
||||
{
|
||||
GConfValue *value;
|
||||
gboolean use_single_click = FALSE;
|
||||
gchar *policy;
|
||||
|
||||
value = gconf_entry_get_value (entry);
|
||||
|
||||
if (value->type == GCONF_VALUE_STRING) {
|
||||
policy = gconf_value_get_string (value);
|
||||
use_single_click = (0 == g_ascii_strcasecmp (policy, "single"));
|
||||
|
||||
gnomecc_canvas_set_single_click_mode (canvas, use_single_click);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
set_click_policy (GnomeccCanvas *canvas)
|
||||
{
|
||||
GConfClient *client = gconf_client_get_default ();
|
||||
gboolean use_single_click = FALSE;
|
||||
gchar *policy;
|
||||
|
||||
gconf_client_add_dir (client,
|
||||
SINGLE_CLICK_POLICY_KEY,
|
||||
GCONF_CLIENT_PRELOAD_NONE,
|
||||
NULL);
|
||||
|
||||
gconf_client_notify_add (client,
|
||||
SINGLE_CLICK_POLICY_KEY,
|
||||
on_click_policy_notified,
|
||||
canvas,
|
||||
NULL, NULL);
|
||||
|
||||
policy = gconf_client_get_string (client, SINGLE_CLICK_POLICY_KEY, NULL);
|
||||
|
||||
if (policy) {
|
||||
use_single_click = (0 == g_ascii_strcasecmp (policy, "single"));
|
||||
g_free (policy);
|
||||
}
|
||||
|
||||
gnomecc_canvas_set_single_click_mode (canvas, use_single_click);
|
||||
}
|
||||
|
||||
|
||||
static GtkWindow *
|
||||
create_window (void)
|
||||
{
|
||||
|
@ -49,6 +100,7 @@ create_window (void)
|
|||
canvas = gnomecc_canvas_new (info);
|
||||
g_signal_connect (G_OBJECT (canvas), "selection-changed",
|
||||
G_CALLBACK (change_status), appbar);
|
||||
set_click_policy (GNOMECC_CANVAS (canvas));
|
||||
|
||||
sw = gtk_scrolled_window_new (GTK_ADJUSTMENT (gtk_adjustment_new (0, 0, 100, 10, 100, 100)),
|
||||
GTK_ADJUSTMENT (gtk_adjustment_new (0, 0, 100, 10, 100, 100)));
|
||||
|
|
|
@ -63,6 +63,8 @@ struct _GnomeccCanvasPrivate {
|
|||
|
||||
/* accessibility stuff */
|
||||
GHashTable *accessible_children;
|
||||
|
||||
gboolean single_click;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
|
@ -187,28 +189,19 @@ gnomecc_canvas_init (GnomeccCanvas *canvas)
|
|||
priv->rtl = (gtk_widget_get_direction (GTK_WIDGET (canvas)) == GTK_TEXT_DIR_RTL);
|
||||
|
||||
priv->accessible_children = g_hash_table_new (g_int_hash, g_int_equal);
|
||||
priv->single_click = FALSE;
|
||||
|
||||
gtk_widget_show_all (GTK_WIDGET (canvas));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
single_click_activates (void)
|
||||
single_click_activates (GnomeccCanvas *canvas)
|
||||
{
|
||||
static gboolean needs_init = TRUE;
|
||||
static gboolean use_single_click = FALSE;
|
||||
if (needs_init) {
|
||||
GConfClient *client = gconf_client_get_default ();
|
||||
char *policy = gconf_client_get_string (client, "/apps/nautilus/preferences/click_policy", NULL);
|
||||
g_object_unref (G_OBJECT (client));
|
||||
GnomeccCanvasPrivate *priv;
|
||||
|
||||
if (policy != NULL) {
|
||||
use_single_click = (0 == g_ascii_strcasecmp (policy, "single"));
|
||||
g_free (policy);
|
||||
}
|
||||
needs_init = FALSE;
|
||||
}
|
||||
priv = GNOMECC_CANVAS_GET_PRIVATE (canvas);
|
||||
|
||||
return use_single_click;
|
||||
return priv->single_click;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -327,22 +320,31 @@ cover_event (GnomeCanvasItem *item, GdkEvent *event, ControlCenterEntry *entry)
|
|||
{
|
||||
EntryInfo *ei = entry->user_data;
|
||||
GnomeccCanvas *canvas = ei->canvas;
|
||||
GdkCursor *cursor;
|
||||
|
||||
switch (event->type) {
|
||||
case GDK_ENTER_NOTIFY:
|
||||
ei->highlighted = TRUE;
|
||||
setup_entry (canvas, entry); /* highlight even if it is already selected */
|
||||
|
||||
if (single_click_activates (canvas)) {
|
||||
cursor = gdk_cursor_new (GDK_HAND1);
|
||||
gdk_window_set_cursor (GTK_WIDGET (canvas)->window, cursor);
|
||||
gdk_cursor_unref (cursor);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
case GDK_LEAVE_NOTIFY:
|
||||
ei->highlighted = FALSE;
|
||||
setup_entry (canvas, entry);
|
||||
gdk_window_set_cursor (GTK_WIDGET (canvas)->window, NULL);
|
||||
return TRUE;
|
||||
case GDK_BUTTON_PRESS:
|
||||
if (single_click_activates ()) {
|
||||
activate_entry (entry);
|
||||
} else {
|
||||
select_entry (canvas, entry);
|
||||
}
|
||||
|
||||
if (single_click_activates (canvas))
|
||||
activate_entry (entry);
|
||||
|
||||
return TRUE;
|
||||
case GDK_2BUTTON_PRESS:
|
||||
activate_entry (entry);
|
||||
|
@ -1701,3 +1703,15 @@ gnomecc_canvas_get_accessible (GtkWidget *widget)
|
|||
|
||||
return (* GTK_WIDGET_CLASS (gnomecc_canvas_parent_class)->get_accessible) (widget);
|
||||
}
|
||||
|
||||
void
|
||||
gnomecc_canvas_set_single_click_mode (GnomeccCanvas *canvas, gboolean single_click)
|
||||
{
|
||||
GnomeccCanvasPrivate *priv;
|
||||
|
||||
g_return_if_fail (GNOMECC_IS_CANVAS (canvas));
|
||||
|
||||
priv = GNOMECC_CANVAS_GET_PRIVATE (canvas);
|
||||
|
||||
priv->single_click = (single_click == TRUE);
|
||||
}
|
||||
|
|
|
@ -53,6 +53,8 @@ struct _GnomeccCanvasClass {
|
|||
GType gnomecc_canvas_get_type (void);
|
||||
|
||||
GtkWidget* gnomecc_canvas_new (ControlCenterInformation *info);
|
||||
void gnomecc_canvas_set_single_click_mode (GnomeccCanvas *canvas, gboolean single_click);
|
||||
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue