Patch by: Matthias Clasen <mclasen@redhat.com>
2008-08-16 Jens Granseuer <jensgr@gmx.net> Patch by: Matthias Clasen <mclasen@redhat.com> * sound-theme.c: (play_sound_at_path), (custom_treeview_button_press_event_cb), (activatable_cell_renderer_pixbuf_activate), (activatable_cell_renderer_pixbuf_init), (activatable_cell_renderer_pixbuf_class_init), (setup_sound_theme_custom): make the event sound preview button listen to the "activate" signal so it becomes accessible via keyboard (bug #547808) svn path=/trunk/; revision=8867
This commit is contained in:
parent
eb329311de
commit
eef20ec03e
2 changed files with 105 additions and 40 deletions
|
@ -1,3 +1,16 @@
|
||||||
|
2008-08-16 Jens Granseuer <jensgr@gmx.net>
|
||||||
|
|
||||||
|
Patch by: Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
|
* sound-theme.c: (play_sound_at_path),
|
||||||
|
(custom_treeview_button_press_event_cb),
|
||||||
|
(activatable_cell_renderer_pixbuf_activate),
|
||||||
|
(activatable_cell_renderer_pixbuf_init),
|
||||||
|
(activatable_cell_renderer_pixbuf_class_init),
|
||||||
|
(setup_sound_theme_custom): make the event sound preview button
|
||||||
|
listen to the "activate" signal so it becomes accessible via
|
||||||
|
keyboard (bug #547808)
|
||||||
|
|
||||||
2008-08-07 Jens Granseuer <jensgr@gmx.net>
|
2008-08-07 Jens Granseuer <jensgr@gmx.net>
|
||||||
|
|
||||||
Based on a patch by: Bastien Nocera <hadess@hadess.net>
|
Based on a patch by: Bastien Nocera <hadess@hadess.net>
|
||||||
|
|
|
@ -985,6 +985,50 @@ theme_changed_custom_init (GtkTreeModel *model,
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
play_sound_at_path (GtkWidget *tree_view,
|
||||||
|
GtkTreeViewColumn *column,
|
||||||
|
GtkTreePath *path)
|
||||||
|
{
|
||||||
|
GObject *preview_column;
|
||||||
|
|
||||||
|
preview_column = g_object_get_data (G_OBJECT (tree_view), "preview-column");
|
||||||
|
if (column == (GtkTreeViewColumn *) preview_column) {
|
||||||
|
GtkTreeModel *model;
|
||||||
|
GtkTreeIter iter;
|
||||||
|
char **sound_names;
|
||||||
|
gboolean sensitive;
|
||||||
|
ca_context *ctx;
|
||||||
|
|
||||||
|
model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view));
|
||||||
|
if (gtk_tree_model_get_iter (model, &iter, path) == FALSE) {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
gtk_tree_model_get (model, &iter,
|
||||||
|
SOUND_NAMES_COL, &sound_names,
|
||||||
|
SENSITIVE_COL, &sensitive, -1);
|
||||||
|
if (!sensitive || sound_names == NULL)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
ctx = ca_gtk_context_get ();
|
||||||
|
ca_gtk_play_for_widget (GTK_WIDGET (tree_view), 0,
|
||||||
|
CA_PROP_APPLICATION_NAME, _("Sound Preferences"),
|
||||||
|
CA_PROP_EVENT_ID, sound_names[0],
|
||||||
|
CA_PROP_EVENT_DESCRIPTION, _("Testing event sound"),
|
||||||
|
CA_PROP_CANBERRA_CACHE_CONTROL, "never",
|
||||||
|
#ifdef CA_PROP_CANBERRA_ENABLE
|
||||||
|
CA_PROP_CANBERRA_ENABLE, "1",
|
||||||
|
#endif
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
g_strfreev (sound_names);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
custom_treeview_button_press_event_cb (GtkWidget *tree_view,
|
custom_treeview_button_press_event_cb (GtkWidget *tree_view,
|
||||||
GdkEventButton *event,
|
GdkEventButton *event,
|
||||||
|
@ -993,6 +1037,7 @@ custom_treeview_button_press_event_cb (GtkWidget *tree_view,
|
||||||
GtkTreePath *path;
|
GtkTreePath *path;
|
||||||
GtkTreeViewColumn *column;
|
GtkTreeViewColumn *column;
|
||||||
GdkEventButton *button_event = (GdkEventButton *) event;
|
GdkEventButton *button_event = (GdkEventButton *) event;
|
||||||
|
gboolean res = FALSE;
|
||||||
|
|
||||||
if (event->type != GDK_BUTTON_PRESS)
|
if (event->type != GDK_BUTTON_PRESS)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -1000,49 +1045,56 @@ custom_treeview_button_press_event_cb (GtkWidget *tree_view,
|
||||||
if (gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (tree_view),
|
if (gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (tree_view),
|
||||||
button_event->x, button_event->y,
|
button_event->x, button_event->y,
|
||||||
&path, &column, NULL, NULL)) {
|
&path, &column, NULL, NULL)) {
|
||||||
GObject *preview_column;
|
res = play_sound_at_path (tree_view, column, path);
|
||||||
|
gtk_tree_path_free (path);
|
||||||
preview_column = g_object_get_data (G_OBJECT (tree_view), "preview-column");
|
|
||||||
if (column == (GtkTreeViewColumn *) preview_column) {
|
|
||||||
GtkTreeModel *model;
|
|
||||||
GtkTreeIter iter;
|
|
||||||
char **sound_names;
|
|
||||||
gboolean sensitive;
|
|
||||||
ca_context *ctx;
|
|
||||||
|
|
||||||
model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view));
|
|
||||||
if (gtk_tree_model_get_iter (model, &iter, path) == FALSE) {
|
|
||||||
gtk_tree_path_free (path);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
gtk_tree_path_free (path);
|
|
||||||
|
|
||||||
gtk_tree_model_get (model, &iter,
|
|
||||||
SOUND_NAMES_COL, &sound_names,
|
|
||||||
SENSITIVE_COL, &sensitive, -1);
|
|
||||||
if (!sensitive || sound_names == NULL)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
ctx = ca_gtk_context_get ();
|
|
||||||
ca_gtk_play_for_widget (GTK_WIDGET (tree_view), 0,
|
|
||||||
CA_PROP_APPLICATION_NAME, _("Sound Preferences"),
|
|
||||||
CA_PROP_EVENT_ID, sound_names[0],
|
|
||||||
CA_PROP_EVENT_DESCRIPTION, _("Testing event sound"),
|
|
||||||
CA_PROP_CANBERRA_CACHE_CONTROL, "never",
|
|
||||||
#ifdef CA_PROP_CANBERRA_ENABLE
|
|
||||||
CA_PROP_CANBERRA_ENABLE, "1",
|
|
||||||
#endif
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
g_strfreev (sound_names);
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typedef GtkCellRendererPixbuf ActivatableCellRendererPixbuf;
|
||||||
|
typedef GtkCellRendererPixbufClass ActivatableCellRendererPixbufClass;
|
||||||
|
|
||||||
|
#define ACTIVATABLE_TYPE_CELL_RENDERER_PIXBUF (activatable_cell_renderer_pixbuf_get_type ())
|
||||||
|
G_DEFINE_TYPE (ActivatableCellRendererPixbuf, activatable_cell_renderer_pixbuf, GTK_TYPE_CELL_RENDERER_PIXBUF);
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
activatable_cell_renderer_pixbuf_activate (GtkCellRenderer *cell,
|
||||||
|
GdkEvent *event,
|
||||||
|
GtkWidget *widget,
|
||||||
|
const gchar *path_string,
|
||||||
|
GdkRectangle *background_area,
|
||||||
|
GdkRectangle *cell_area,
|
||||||
|
GtkCellRendererState flags)
|
||||||
|
{
|
||||||
|
GtkTreeViewColumn *preview_column;
|
||||||
|
GtkTreePath *path;
|
||||||
|
gboolean res;
|
||||||
|
|
||||||
|
preview_column = g_object_get_data (G_OBJECT (widget), "preview-column");
|
||||||
|
path = gtk_tree_path_new_from_string (path_string);
|
||||||
|
res = play_sound_at_path (widget, preview_column, path);
|
||||||
|
gtk_tree_path_free (path);
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
activatable_cell_renderer_pixbuf_init (ActivatableCellRendererPixbuf *cell)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
activatable_cell_renderer_pixbuf_class_init (ActivatableCellRendererPixbufClass *class)
|
||||||
|
{
|
||||||
|
GtkCellRendererClass *cell_class;
|
||||||
|
|
||||||
|
cell_class = GTK_CELL_RENDERER_CLASS (class);
|
||||||
|
|
||||||
|
cell_class->activate = activatable_cell_renderer_pixbuf_activate;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
setup_sound_theme_custom (GladeXML *dialog, gboolean have_xkb)
|
setup_sound_theme_custom (GladeXML *dialog, gboolean have_xkb)
|
||||||
{
|
{
|
||||||
|
@ -1088,7 +1140,7 @@ setup_sound_theme_custom (GladeXML *dialog, gboolean have_xkb)
|
||||||
gtk_tree_view_column_set_cell_data_func (column, renderer, setting_set_func, NULL, NULL);
|
gtk_tree_view_column_set_cell_data_func (column, renderer, setting_set_func, NULL, NULL);
|
||||||
|
|
||||||
/* The 3rd column with the preview pixbuf */
|
/* The 3rd column with the preview pixbuf */
|
||||||
renderer = gtk_cell_renderer_pixbuf_new ();
|
renderer = g_object_new (ACTIVATABLE_TYPE_CELL_RENDERER_PIXBUF, NULL);
|
||||||
g_object_set (renderer,
|
g_object_set (renderer,
|
||||||
"mode", GTK_CELL_RENDERER_MODE_ACTIVATABLE,
|
"mode", GTK_CELL_RENDERER_MODE_ACTIVATABLE,
|
||||||
"icon-name", "media-playback-start",
|
"icon-name", "media-playback-start",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue