static GtkWidget* my_gtk_dialog_get_widget_for_response (GtkDialog *dialog,gint response_id) { GList *children; GList *tmp_list; g_return_val_if_fail (GTK_IS_DIALOG (dialog), NULL); children = gtk_container_get_children (GTK_CONTAINER (dialog->action_area)); tmp_list = children; while (tmp_list != NULL) { GtkWidget *widget = tmp_list->data; ResponseData *rd = get_response_data (widget, FALSE); if (rd && rd->response_id == response_id) { g_list_free (children); return widget; } tmp_list = g_list_next (tmp_list); } g_list_free (children); return NULL; }
static void action_widget_activated( GtkWidget *widget, UCViewInfoBox *box ) { ResponseData *rd; rd = get_response_data( widget, FALSE ); ucview_info_box_response( box, rd ? rd->response_id : GTK_RESPONSE_NONE ); }
void ucview_info_box_add_action_widget( UCViewInfoBox *box, GtkWidget *widget, gint response_id ) { ResponseData *rd; guint signal_id; g_return_if_fail( IS_UCVIEW_INFO_BOX( box ) ); g_return_if_fail( GTK_IS_WIDGET( widget ) ); rd = get_response_data( widget, TRUE ); rd->response_id = response_id; if( GTK_IS_BUTTON( widget ) ) { signal_id = g_signal_lookup( "clicked", GTK_TYPE_BUTTON ); } else { signal_id = GTK_WIDGET_GET_CLASS( widget )->activate_signal; } if( signal_id ) { GClosure *closure; closure = g_cclosure_new_object( G_CALLBACK( action_widget_activated ), G_OBJECT( box ) ); g_signal_connect_closure_by_id( widget, signal_id, 0, closure, FALSE ); } else { g_warning( "UCViewInfoBox: add_action_widget: Item not activatable" ); } if( response_id != GTK_RESPONSE_HELP ) { gtk_box_pack_start( GTK_BOX( box->priv->action_box ), widget, FALSE, FALSE, 12 ); } else { gtk_box_pack_end( GTK_BOX( box->priv->action_box ), widget, FALSE, FALSE, 12 ); } }