579
/* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */
582
gint hbtk_radio_button_get_active (GtkContainer *container)
584
GList *lchild, *list;
588
if(!GTK_IS_CONTAINER(container))
591
lchild = list = gtk_container_get_children (container);
592
for(i=0;list != NULL;i++)
595
if(GTK_IS_TOGGLE_BUTTON(radio))
597
if( gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radio)) == TRUE )
603
list = g_list_next(list);
611
void hbtk_radio_button_set_active (GtkContainer *container, gint active)
613
GList *lchild, *list;
616
if(!GTK_IS_CONTAINER(container))
619
lchild = list = gtk_container_get_children (container);
620
radio = g_list_nth_data (list, active);
621
if(radio != NULL && GTK_IS_TOGGLE_BUTTON(radio))
623
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(radio), TRUE);
629
GtkWidget *hbtk_radio_button_get_nth (GtkContainer *container, gint nth)
631
GList *lchild, *list;
634
if(!GTK_IS_CONTAINER(container))
637
lchild = list = gtk_container_get_children (container);
638
radio = g_list_nth_data (list, nth);
640
return radio; //may return NULL
644
void hbtk_radio_button_unblock_by_func(GtkContainer *container, GCallback c_handler, gpointer data)
646
GList *lchild, *list;
650
if(!GTK_IS_CONTAINER(container))
653
lchild = list = gtk_container_get_children (container);
654
for(i=0;list != NULL;i++)
657
if(GTK_IS_TOGGLE_BUTTON(radio))
659
g_signal_handlers_unblock_by_func (radio, c_handler, data);
661
list = g_list_next(list);
667
void hbtk_radio_button_block_by_func(GtkContainer *container, GCallback c_handler, gpointer data)
669
GList *lchild, *list;
673
if(!GTK_IS_CONTAINER(container))
676
lchild = list = gtk_container_get_children (container);
677
for(i=0;list != NULL;i++)
680
if(GTK_IS_TOGGLE_BUTTON(radio))
682
g_signal_handlers_block_by_func (radio, c_handler, data);
684
list = g_list_next(list);
690
void hbtk_radio_button_connect(GtkContainer *container, const gchar *detailed_signal, GCallback c_handler, gpointer data)
692
GList *lchild, *list;
696
if(!GTK_IS_CONTAINER(container))
699
lchild = list = gtk_container_get_children (container);
700
for(i=0;list != NULL;i++)
703
if(GTK_IS_TOGGLE_BUTTON(radio))
705
g_signal_connect (radio, "toggled", c_handler, data);
707
list = g_list_next(list);
714
GtkWidget *hbtk_radio_button_new (gchar **items, gboolean buttonstyle)
716
GtkWidget *box, *button, *newbutton;
719
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
721
button = gtk_radio_button_new_with_label (NULL, _(items[0]));
722
gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (button), !buttonstyle);
723
gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 0);
724
for (i = 1; items[i] != NULL; i++)
726
newbutton = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (button), _(items[i]));
727
gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (newbutton), !buttonstyle);
728
gtk_box_pack_start (GTK_BOX (box), newbutton, FALSE, FALSE, 0);
733
gtk_style_context_add_class (gtk_widget_get_style_context (box), GTK_STYLE_CLASS_LINKED);
734
gtk_style_context_add_class (gtk_widget_get_style_context (box), GTK_STYLE_CLASS_RAISED);
741
/* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */
583
745
is_separator (GtkTreeModel *model,
584
746
GtkTreeIter *iter,
649
GtkWidget *make_daterange(GtkWidget *label, gboolean custom)
652
GList *renderers, *list;
653
GtkCellRenderer *renderer;
654
gchar **items = CYA_FLT_RANGE;
657
combobox = gtk_combo_box_text_new ();
659
for (i = 0; items[i] != NULL; i++)
662
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT(combobox), _(items[i]));
664
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT(combobox), "");
666
gtk_combo_box_set_active(GTK_COMBO_BOX(combobox), 0);
669
gtk_label_set_mnemonic_widget (GTK_LABEL(label), combobox);
672
renderers = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT(combobox));
673
if(g_list_length(renderers) == 1 && custom == FALSE)
675
list = g_list_first(renderers);
676
renderer = list->data;
679
gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (combobox),
684
g_list_free(renderers);
686
gtk_combo_box_set_row_separator_func (GTK_COMBO_BOX (combobox), is_separator, NULL, NULL);
692
792
/* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */
694
795
#define HB_KV_BUFFER_MAX_LEN 8
695
796
#define HB_KV_ITEMS_MAX_LEN 32
808
909
/* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */
811
gint hbtk_radio_get_active (GtkContainer *container)
813
GList *lchild, *list;
817
if(!GTK_IS_CONTAINER(container))
820
lchild = list = gtk_container_get_children (container);
821
for(i=0;list != NULL;i++)
824
if(GTK_IS_TOGGLE_BUTTON(radio))
826
if( gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radio)) == TRUE )
832
list = g_list_next(list);
840
void hbtk_radio_set_active (GtkContainer *container, gint active)
842
GList *lchild, *list;
845
if(!GTK_IS_CONTAINER(container))
848
lchild = list = gtk_container_get_children (container);
849
radio = g_list_nth_data (list, active);
850
if(radio != NULL && GTK_IS_TOGGLE_BUTTON(radio))
852
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(radio), TRUE);
858
GtkWidget *hbtk_radio_get_nth (GtkContainer *container, gint nth)
860
GList *lchild, *list;
863
if(!GTK_IS_CONTAINER(container))
866
lchild = list = gtk_container_get_children (container);
867
radio = g_list_nth_data (list, nth);
869
return radio; //may return NULL
873
void hbtk_radio_connect(GtkContainer *container, const gchar *detailed_signal, GCallback c_handler, gpointer data)
875
GList *lchild, *list;
879
if(!GTK_IS_CONTAINER(container))
882
lchild = list = gtk_container_get_children (container);
883
for(i=0;list != NULL;i++)
886
if(GTK_IS_TOGGLE_BUTTON(radio))
888
g_signal_connect (radio, "toggled", c_handler, data);
890
list = g_list_next(list);
897
GtkWidget *hbtk_radio_new (gchar **items, gboolean buttonstyle)
899
GtkWidget *box, *button, *newbutton;
902
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
904
button = gtk_radio_button_new_with_label (NULL, _(items[0]));
905
gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (button), !buttonstyle);
906
gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 0);
907
for (i = 1; items[i] != NULL; i++)
909
newbutton = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (button), _(items[i]));
910
gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (newbutton), !buttonstyle);
911
gtk_box_pack_start (GTK_BOX (box), newbutton, FALSE, FALSE, 0);
916
gtk_style_context_add_class (gtk_widget_get_style_context (box), GTK_STYLE_CLASS_LINKED);
917
gtk_style_context_add_class (gtk_widget_get_style_context (box), GTK_STYLE_CLASS_RAISED);
912
set_sensitive (GtkCellLayout *cell_layout,
913
GtkCellRenderer *cell,
914
GtkTreeModel *tree_model,
922
path = gtk_tree_model_get_path (tree_model, iter);
923
indices = gtk_tree_path_get_indices (path);
924
sensitive = indices[0] != FLT_RANGE_OTHER;
925
gtk_tree_path_free (path);
927
g_object_set (cell, "sensitive", sensitive, NULL);
932
GtkWidget *make_daterange(GtkWidget *label, guint dspmode)
934
GtkWidget *combobox = hbtk_combo_box_new(label);
935
GList *renderers, *list;
936
HbKvData *tmp, *kvdata = CYA_FLT_RANGE;
939
for(i=0;i<HB_KV_ITEMS_MAX_LEN;i++)
942
if( tmp->name == NULL )
945
if( (tmp->key == FLT_RANGE_OTHER) )
947
if( dspmode == DATE_RANGE_CUSTOM_DISABLE )
949
renderers = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT(combobox));
950
if(g_list_length(renderers) == 1)
952
list = g_list_first(renderers);
953
gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (combobox),
958
g_list_free(renderers);
961
if( dspmode == DATE_RANGE_CUSTOM_HIDE )
963
//if hide, we do not show it
969
hbtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(combobox), tmp->key, (*tmp->name != 0) ? (gchar *)_(tmp->name) : (gchar *)"");
972
gtk_combo_box_set_active(GTK_COMBO_BOX(combobox), 0);
973
gtk_combo_box_set_row_separator_func (GTK_COMBO_BOX (combobox), hbtk_combo_box_is_separator, NULL, NULL);