mp3splt-gtk
|
00001 /********************************************************** 00002 * 00003 * mp3splt-gtk -- utility based on mp3splt, 00004 * for mp3/ogg splitting without decoding 00005 * 00006 * Copyright: (C) 2005-2012 Alexandru Munteanu 00007 * Contact: io_fx@yahoo.fr 00008 * 00009 * http://mp3splt.sourceforge.net/ 00010 * 00011 *********************************************************/ 00012 00013 /********************************************************** 00014 * 00015 * This program is free software; you can redistribute it and/or 00016 * modify it under the terms of the GNU General Public License 00017 * as published by the Free Software Foundation; either version 2 00018 * of the License, or (at your option) any later version. 00019 * 00020 * This program is distributed in the hope that it will be useful, 00021 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00022 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00023 * GNU General Public License for more details. 00024 * 00025 * You should have received a copy of the GNU General Public License 00026 * along with this program; if not, write to the Free Software 00027 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 00028 * USA. 00029 * 00030 *********************************************************/ 00031 00032 /*!******************************************************** 00033 * \file 00034 * 00035 * this file contains the code for the radio button helpers. 00036 ********************************************************/ 00037 00038 #include "radio_helper.h" 00039 00040 GtkWidget *rh_append_radio_to_vbox(GtkWidget *radio_button, const gchar *text, 00041 gint value, 00042 void (*callback)(GtkToggleButton *, gpointer), 00043 GtkWidget *vbox) 00044 { 00045 GtkWidget *new_radio_button = 00046 gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(radio_button), text); 00047 gtk_box_pack_start(GTK_BOX(vbox), new_radio_button, FALSE, FALSE, 0); 00048 00049 if (callback) 00050 { 00051 g_signal_connect(GTK_TOGGLE_BUTTON(new_radio_button), "toggled", G_CALLBACK(callback), 00052 NULL); 00053 } 00054 00055 g_object_set_data(G_OBJECT(new_radio_button), "value", GINT_TO_POINTER(value)); 00056 00057 return new_radio_button; 00058 } 00059 00060 gint rh_get_active_value(GtkWidget *radio_button) 00061 { 00062 gint active_value = -1; 00063 GSList *radio_button_list = gtk_radio_button_get_group(GTK_RADIO_BUTTON(radio_button)); 00064 00065 gint i = 0; 00066 for(i = 0; i < g_slist_length(radio_button_list);i++) 00067 { 00068 GtkRadioButton *current_radio = (GtkRadioButton *) g_slist_nth_data(radio_button_list, i); 00069 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(current_radio))) 00070 { 00071 active_value = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(current_radio), "value")); 00072 break; 00073 } 00074 } 00075 00076 return active_value; 00077 } 00078 00079 GtkWidget *rh_get_radio_from_value(GtkWidget *radio_button, gint value) 00080 { 00081 GtkWidget *radio = NULL; 00082 GSList *radio_button_list = gtk_radio_button_get_group(GTK_RADIO_BUTTON(radio_button)); 00083 00084 gint i = 0; 00085 for(i = 0; i < g_slist_length(radio_button_list);i++) 00086 { 00087 GtkRadioButton *current_radio = (GtkRadioButton *) g_slist_nth_data(radio_button_list, i); 00088 gint current_value = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(current_radio), "value")); 00089 if (current_value == value) 00090 { 00091 radio = GTK_WIDGET(current_radio); 00092 break; 00093 } 00094 } 00095 00096 return radio; 00097 } 00098