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>
|
||||
|
||||
Based on a patch by: Bastien Nocera <hadess@hadess.net>
|
||||
|
|
|
@ -986,20 +986,10 @@ theme_changed_custom_init (GtkTreeModel *model,
|
|||
}
|
||||
|
||||
static gboolean
|
||||
custom_treeview_button_press_event_cb (GtkWidget *tree_view,
|
||||
GdkEventButton *event,
|
||||
GladeXML *dialog)
|
||||
play_sound_at_path (GtkWidget *tree_view,
|
||||
GtkTreeViewColumn *column,
|
||||
GtkTreePath *path)
|
||||
{
|
||||
GtkTreePath *path;
|
||||
GtkTreeViewColumn *column;
|
||||
GdkEventButton *button_event = (GdkEventButton *) event;
|
||||
|
||||
if (event->type != GDK_BUTTON_PRESS)
|
||||
return TRUE;
|
||||
|
||||
if (gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (tree_view),
|
||||
button_event->x, button_event->y,
|
||||
&path, &column, NULL, NULL)) {
|
||||
GObject *preview_column;
|
||||
|
||||
preview_column = g_object_get_data (G_OBJECT (tree_view), "preview-column");
|
||||
|
@ -1012,10 +1002,8 @@ custom_treeview_button_press_event_cb (GtkWidget *tree_view,
|
|||
|
||||
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,
|
||||
|
@ -1038,11 +1026,75 @@ custom_treeview_button_press_event_cb (GtkWidget *tree_view,
|
|||
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
custom_treeview_button_press_event_cb (GtkWidget *tree_view,
|
||||
GdkEventButton *event,
|
||||
GladeXML *dialog)
|
||||
{
|
||||
GtkTreePath *path;
|
||||
GtkTreeViewColumn *column;
|
||||
GdkEventButton *button_event = (GdkEventButton *) event;
|
||||
gboolean res = FALSE;
|
||||
|
||||
if (event->type != GDK_BUTTON_PRESS)
|
||||
return TRUE;
|
||||
|
||||
if (gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (tree_view),
|
||||
button_event->x, button_event->y,
|
||||
&path, &column, NULL, NULL)) {
|
||||
res = play_sound_at_path (tree_view, column, path);
|
||||
gtk_tree_path_free (path);
|
||||
}
|
||||
|
||||
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
|
||||
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);
|
||||
|
||||
/* 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,
|
||||
"mode", GTK_CELL_RENDERER_MODE_ACTIVATABLE,
|
||||
"icon-name", "media-playback-start",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue