void
properties_cb (GtkAction *action, SeahorseApplet *sapplet)
{
    SeahorseWidget *swidget;
    GtkWidget *widget;
    GdkPixbuf *pixbuf;
    
    swidget = seahorse_widget_new ("applet-preferences", NULL);
    
    widget = GTK_WIDGET (seahorse_widget_get_widget (swidget, swidget->name));

    pixbuf = gtk_widget_render_icon (widget, 
                                     ICON_CLIPBOARD_DEFAULT, 
                                     (GtkIconSize)-1, 
                                     NULL);
                                     
    gtk_window_set_icon (GTK_WINDOW (widget), pixbuf);
    
    g_object_unref(pixbuf);
    
    /* Preferences window is already open */
    if (!swidget)
        return;
    
    widget = GTK_WIDGET (seahorse_widget_get_widget (swidget, "show-clipboard-state"));
    if (widget && GTK_IS_CHECK_BUTTON (widget))
        seahorse_check_button_gconf_attach (GTK_CHECK_BUTTON (widget), SHOW_CLIPBOARD_STATE_KEY);
    
    widget = GTK_WIDGET (seahorse_widget_get_widget (swidget, "display-encrypted-clipboard"));
    if (widget && GTK_IS_CHECK_BUTTON (widget))
        seahorse_check_button_gconf_attach (GTK_CHECK_BUTTON (widget), DISPLAY_CLIPBOARD_ENC_KEY);
    
    widget = GTK_WIDGET (seahorse_widget_get_widget (swidget, "display-decrypted-clipboard"));
    if (widget && GTK_IS_CHECK_BUTTON (widget))
        seahorse_check_button_gconf_attach (GTK_CHECK_BUTTON (widget), DISPLAY_CLIPBOARD_DEC_KEY);
        
    widget = GTK_WIDGET (seahorse_widget_get_widget (swidget, "display-verified-clipboard"));
    if (widget && GTK_IS_CHECK_BUTTON (widget))
        seahorse_check_button_gconf_attach (GTK_CHECK_BUTTON (widget), DISPLAY_CLIPBOARD_VER_KEY);

    widget = GTK_WIDGET (seahorse_widget_get_widget (swidget, "close"));
    g_signal_connect (widget, "clicked", G_CALLBACK (close_props), swidget);

    widget = seahorse_widget_get_toplevel (swidget);
    g_signal_connect (widget, "delete-event", G_CALLBACK (win_destroyed), swidget);

    seahorse_widget_show (swidget);
}
void
test_wheel_axes (gconstpointer data)
{
    GtkWidget *button;
    gint widget_value;
    const gchar *widget_name;
    WheelAxisAssertFunction assert_function;

    widget_name = gcut_data_get_string(data, "widget-name");
    assert_function = gcut_data_get_pointer(data, "assert-function");

    enable_widget("wheel_emulation_box");

    button = get_widget(widget_name);
    cut_assert_true(GTK_IS_CHECK_BUTTON(button));

    cut_assert_equal_int(4, get_scroll_axes_property_of_xinput());
    widget_value = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button));
    assert_function(widget_value);

    gtk_test_widget_click(button, 1, 0);
    wait_action();
    cut_assert_equal_int(4, get_scroll_axes_property_of_xinput());
    widget_value = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button));
    assert_function(widget_value);
}
static void make_widget_update_signal_based(struct iio_widget *widgets,
	unsigned int num_widgets)
{
	char signal_name[25];
	unsigned int i;

	for (i = 0; i < num_widgets; i++) {
		if (GTK_IS_CHECK_BUTTON(widgets[i].widget))
			sprintf(signal_name, "%s", "toggled");
		else if (GTK_IS_TOGGLE_BUTTON(widgets[i].widget))
			sprintf(signal_name, "%s", "toggled");
		else if (GTK_IS_SPIN_BUTTON(widgets[i].widget))
			sprintf(signal_name, "%s", "value-changed");
		else if (GTK_IS_COMBO_BOX_TEXT(widgets[i].widget))
			sprintf(signal_name, "%s", "changed");
		else
			printf("unhandled widget type, attribute: %s\n", widgets[i].attr_name);

		if (GTK_IS_SPIN_BUTTON(widgets[i].widget) &&
			widgets[i].priv_progress != NULL) {
				iio_spin_button_progress_activate(&widgets[i]);
		} else {
			g_signal_connect(G_OBJECT(widgets[i].widget), signal_name, G_CALLBACK(save_widget_value), &widgets[i]);
		}
	}
}
static void
send_response (AccessDialogHandle *handle)
{
  GVariantBuilder opt_builder;

  g_variant_builder_init (&opt_builder, G_VARIANT_TYPE_VARDICT);

  if (handle->request->exported)
    request_unexport (handle->request);

  if (handle->response == 0 && handle->choices != NULL)
    {
      GVariantBuilder choice_builder;
      GHashTableIter iter;
      const char *key;
      GtkWidget *widget;

      g_variant_builder_init (&choice_builder, G_VARIANT_TYPE_VARDICT);
      g_hash_table_iter_init (&iter, handle->choices);
      while (g_hash_table_iter_next (&iter, (gpointer *)&key, (gpointer *)&widget))
        {
          if (GTK_IS_RADIO_BUTTON (widget))
            {
              gchar **str;

              if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
                continue;

              str = g_strsplit (key, ":", -1);
              g_variant_builder_add (&choice_builder, "{sv}", str[0], g_variant_new_string (str[1]));
              g_strfreev (str);
            }
          else if (GTK_IS_CHECK_BUTTON (widget))
            {
              gboolean active;

              active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
              g_variant_builder_add (&choice_builder, "{sv}", key, g_variant_new_string (active ? "true" : "false"));
            }
        }

      g_variant_builder_add (&opt_builder, "{sv}", "choices", g_variant_builder_end (&choice_builder));
    }

  xdp_impl_access_complete_access_dialog (handle->impl,
                                          handle->invocation,
                                          handle->response,
                                          g_variant_builder_end (&opt_builder));

  access_dialog_handle_close (handle);
}
Beispiel #5
0
/** Connect a GtkCheckButton widget to its stored value in the preferences database.
 *
 *  @internal
 *
 *  @param button A pointer to the check button that should be
 *  connected.
 */
static void
gnc_prefs_connect_check_button (GtkCheckButton *button)
{
    gchar *group, *pref;

    g_return_if_fail(GTK_IS_CHECK_BUTTON(button));

    gnc_prefs_split_widget_name (gtk_buildable_get_name(GTK_BUILDABLE(button)), &group, &pref);

    gnc_prefs_bind (group, pref, G_OBJECT (button), "active");

    g_free (group);
    g_free (pref);
}
Beispiel #6
0
Datei: ui.c Projekt: scorpp/db-vk
static void
save_active_property_value_to_config (GtkWidget *widget, gpointer data) {
    GValue value = G_VALUE_INIT;

    if (GTK_IS_COMBO_BOX (widget)) {
        g_value_init (&value, G_TYPE_INT);
    } else if (GTK_IS_CHECK_BUTTON (widget)) {
        g_value_init (&value, G_TYPE_BOOLEAN);
    } else {
        trace ("FATAL: %s unsupported widget type\n", __FUNCTION__);
    }

    g_object_get_property (G_OBJECT (widget), "active", &value);
    vk_set_config_var ((const gchar *) data, &value);
}
Beispiel #7
0
static void
gail_toggle_button_real_initialize (AtkObject *obj,
                                    gpointer  data)
{
  ATK_OBJECT_CLASS (gail_toggle_button_parent_class)->initialize (obj, data);

  g_signal_connect (data,
                    "toggled",
                    G_CALLBACK (gail_toggle_button_toggled_gtk),
                    NULL);

  if (GTK_IS_CHECK_BUTTON (data))
    obj->role = ATK_ROLE_CHECK_BOX;
  else
    obj->role = ATK_ROLE_TOGGLE_BUTTON;
}
Beispiel #8
0
/* hooks up the signals for check and radio buttons */
void
aurora_animation_connect_checkbox (GtkWidget *widget)
{
	if (GTK_IS_CHECK_BUTTON (widget))
	{
		if (!g_slist_find_custom (connected_widgets, widget, find_signal_info))
		{
			SignalInfo * signal_info = g_new (SignalInfo, 1);
			
			signal_info->widget = widget;
			signal_info->handler_id = g_signal_connect ((GObject*)widget, "toggled", G_CALLBACK (on_checkbox_toggle), NULL);
			
			connected_widgets = g_slist_append (connected_widgets, signal_info);
			g_object_weak_ref (G_OBJECT (widget), on_connected_widget_destruction, signal_info);
		}
	}
}
Beispiel #9
0
static void netplay_update_control_res(GtkWidget *w, gpointer data)
{
    unsigned int control, mask;

    g_return_if_fail(GTK_IS_CHECK_BUTTON(w));
    g_return_if_fail(data != 0);

    mask = *((unsigned int *)data);
    resources_get_int("NetworkControl", (int *)&control);
    if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w))) {
        control |= mask;
    } else {
        control &= ~mask;
    }

    resources_set_int("NetworkControl", (int)control);
}
Beispiel #10
0
static void
draw_check (GtkStyle     *style,
	    GdkWindow    *window,
	    GtkStateType  state,
	    GtkShadowType shadow,
	    GdkRectangle *area,
	    GtkWidget    *widget,
	    const gchar  *detail,
	    gint          x,
	    gint          y,
	    gint          width,
	    gint          height)
{
  ThemeMatchData match_data;

  g_return_if_fail (style != NULL);
  g_return_if_fail (window != NULL);

  /* FIXME: memory leak */
  LOG ("widget=%s, primitive=check, state=%s, shadow=%s, detail='%s', name='%s'",
        G_OBJECT_TYPE_NAME (widget),
        enum_value_to_string (gtk_state_type_get_type (), state),
        enum_value_to_string (gtk_shadow_type_get_type (), shadow),
        detail,
        gtk_widget_get_name (widget));

  match_data.function = TOKEN_D_CHECK;
  match_data.detail = (gchar *)detail;
  match_data.flags = THEME_MATCH_SHADOW | THEME_MATCH_STATE;
  match_data.shadow = shadow;
  match_data.state = state;

  /* Special casing for GtkCheckButton: We want to set the widget state to
   * ACTIVE to get the correct graphics used in the RC files. Ideally we'd
   * use the FOCUS rules, but this is not possible due to technical limitations
   * in how focus is drawn in sapwood */
  if (GTK_IS_CHECK_BUTTON (widget) &&
      gtk_widget_has_focus (widget))
    match_data.state = GTK_STATE_ACTIVE;

  if (!draw_simple_image (style, window, area, widget, &match_data, TRUE,
			  x, y, width, height))
    GTK_STYLE_CLASS (sapwood_style_parent_class)->draw_check (
      style, window, state, shadow, area, widget, detail, x, y, width, height);
}
Beispiel #11
0
/** Connect a GtkCheckButton widget to its stored value in the preferences database.
 *
 *  @internal
 *
 *  @param button A pointer to the check button that should be
 *  connected.
 */
static void
gnc_prefs_connect_check_button (GtkCheckButton *button)
{
    gchar *group, *pref;
    gboolean active;

    g_return_if_fail(GTK_IS_CHECK_BUTTON(button));

    gnc_prefs_split_widget_name (gtk_buildable_get_name(GTK_BUILDABLE(button)), &group, &pref);

//    active = gnc_prefs_get_bool (group, pref);
//    DEBUG(" Checkbox %s/%s initially %sactive", group, pref, active ? "" : "in");
//    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), active);

    gnc_prefs_bind (group, pref, G_OBJECT (button), "active");

    g_free (group);
    g_free (pref);
}
Beispiel #12
0
static void InsertWidgetInTable(GtkWidget* table, GtkWidget *left, GtkWidget *right = NULL, GtkWidget *third = NULL) {
	GtkAttachOptions opt = (GtkAttachOptions)(GTK_EXPAND | GTK_FILL); // default
	guint l_xpad = GTK_IS_CHECK_BUTTON(left) ? 0 : 22;
	guint r_xpad = 0;
	guint ypad = 0;
	if (!left) {
		gtk_table_attach(GTK_TABLE(table), right, 1, 2, s_table_line, s_table_line+1, opt, opt, r_xpad, ypad);
	} else if (!right) {
		gtk_table_attach(GTK_TABLE(table), left, 0, 1, s_table_line, s_table_line+1, opt, opt, l_xpad, ypad);
	} else if (right == left) {
		gtk_table_attach(GTK_TABLE(table), left, 0, 2, s_table_line, s_table_line+1, opt, opt, r_xpad, ypad);
	} else {
		gtk_table_attach(GTK_TABLE(table), left, 0, 1, s_table_line, s_table_line+1, opt, opt, l_xpad, ypad);
		gtk_table_attach(GTK_TABLE(table), right, 1, 2, s_table_line, s_table_line+1, opt, opt, r_xpad, ypad);
	}
	if (third) {
		gtk_table_attach(GTK_TABLE(table), third, 2, 3, s_table_line, s_table_line+1, opt, opt, r_xpad, ypad);
	}
	s_table_line++;
}
Beispiel #13
0
void InsertWidgetInTable(GtkWidget* table, GtkWidget *left, GtkWidget *right = NULL, GtkWidget *third = NULL)
{
	guint l_xpad = GTK_IS_CHECK_BUTTON(left) ? 0 : 22;

	if (!left) {
		AttachInTable(table, right, 1);
	} else if (!right) {
		AttachInTable(table, left, 0, l_xpad);
	} else if (right == left) {
		AttachInTable(table, right, 0, 0, 2);
	} else {
		AttachInTable(table, left, 0, l_xpad);
		AttachInTable(table, right, 1);
	}
	if (third) {
		AttachInTable(table, third, 2);
	}

	s_table_line++;
}
static void gconf_dialog_onResetButtonPressed (GConfDialog* self, GtkButton* widget) {
	GConfSchema* schema;
	GConfValue* default_value;
	GtkWidget* target;
	g_return_if_fail (self != NULL);
	g_return_if_fail (widget != NULL);
	schema = (GConfSchema*) g_object_get_data ((GObject*) widget, "gconf-schema");
	default_value = gconf_schema_get_default_value (schema);
	target = _g_object_ref0 ((GtkWidget*) g_object_get_data ((GObject*) widget, "target"));
	switch (gconf_schema_get_type (schema)) {
		case GCONF_VALUE_BOOL:
		{
			GtkWidget* _tmp0_;
			GtkCheckButton* checkbutton;
			checkbutton = _g_object_ref0 ((_tmp0_ = target, GTK_IS_CHECK_BUTTON (_tmp0_) ? ((GtkCheckButton*) _tmp0_) : NULL));
			gtk_toggle_button_set_active ((GtkToggleButton*) checkbutton, gconf_value_get_bool (default_value));
			_g_object_unref0 (checkbutton);
			break;
		}
		case GCONF_VALUE_STRING:
		{
			GtkWidget* _tmp1_;
			GtkEntry* entrybox;
			entrybox = _g_object_ref0 ((_tmp1_ = target, GTK_IS_ENTRY (_tmp1_) ? ((GtkEntry*) _tmp1_) : NULL));
			gtk_entry_set_text (entrybox, gconf_value_get_string (default_value));
			_g_object_unref0 (entrybox);
			break;
		}
		case GCONF_VALUE_INT:
		{
			GtkWidget* _tmp2_;
			GtkSpinButton* spin;
			spin = _g_object_ref0 ((_tmp2_ = target, GTK_IS_SPIN_BUTTON (_tmp2_) ? ((GtkSpinButton*) _tmp2_) : NULL));
			gtk_spin_button_set_value (spin, (double) gconf_value_get_int (default_value));
			_g_object_unref0 (spin);
			break;
		}
	}
	_g_object_unref0 (target);
}
/**
 * hildon_caption_new:
 * @group: a #GtkSizeGroup for controlling the size of related captions or %NULL
 * @value: the caption text to accompany the text entry.  The widget makes
 *          a copy of this text.
 * @control: the control that is to be captioned.
 * @icon: an icon to accompany the label or %NULL in case no icon should be displayed.
 * @flag: indicates whether this captioned control is mandatory or
 *         optional.
 *
 * Creates a new instance of #HildonCaption widget, with a specific
 * control and image.
 * Note: Clicking on a focused caption will trigger the activate signal.
 * The default behaviour for the caption's activate signal is to call	 
 * gtk_widget_activate() on its control.
 * 
 * Returns: a new #HildonCaption
 */
GtkWidget*
hildon_caption_new                              (GtkSizeGroup *group, 
                                                 const gchar *value,
                                                 GtkWidget *child, 
                                                 GtkWidget *icon,
                                                 HildonCaptionStatus flag)
{
    GtkWidget *widget;
    g_return_val_if_fail (GTK_IS_WIDGET (child), NULL);

    widget = g_object_new (HILDON_TYPE_CAPTION, 
            "label", value,
            "child", child, 
            "size_group", group, 
            "icon", icon, 
            "status", flag,
            NULL);

    /* Do not expand GtkCheckButton by default, we want to reduce its activation area */
    if (GTK_IS_CHECK_BUTTON (child))
      hildon_caption_set_child_expand (HILDON_CAPTION (widget), FALSE);

    return widget;
}
Beispiel #16
0
static void gmpc_tools_metadata_appearance_real_preferences_pane_construct (GmpcPluginPreferencesIface* base, GtkContainer* container) {
	GmpcToolsMetadataAppearance * self;
	GtkBuilder* _tmp0_ = NULL;
	GtkBuilder* builder;
	gchar* _tmp1_ = NULL;
	gchar* preferences_ui_file;
	GObject* _tmp2_ = NULL;
	GObject* _tmp3_;
	GtkWidget* _tmp4_;
	GtkWidget* builderWidget;
	GObject* _tmp5_ = NULL;
	GObject* _tmp6_;
	GtkWidget* _tmp7_;
	gint _tmp8_;
	GObject* _tmp9_ = NULL;
	GObject* _tmp10_;
	GtkWidget* _tmp11_;
	gint _tmp12_;
	GObject* _tmp13_ = NULL;
	GObject* _tmp14_;
	GtkWidget* _tmp15_;
	gint _tmp16_;
	GObject* _tmp17_ = NULL;
	GObject* _tmp18_;
	GtkWidget* _tmp19_;
	gint _tmp20_;
	GObject* _tmp21_ = NULL;
	GObject* _tmp22_;
	GtkWidget* _tmp23_;
	gint _tmp24_;
	GObject* _tmp25_ = NULL;
	GObject* _tmp26_;
	GtkWidget* _tmp27_;
	gint _tmp28_;
	GError * _inner_error_ = NULL;
	self = (GmpcToolsMetadataAppearance*) base;
	g_return_if_fail (container != NULL);
	_tmp0_ = gtk_builder_new ();
	builder = _tmp0_;
	_tmp1_ = gmpc_get_full_glade_path ("preferences-metadata-appearance.ui");
	preferences_ui_file = _tmp1_;
	gtk_builder_add_from_file (builder, preferences_ui_file, &_inner_error_);
	if (_inner_error_ != NULL) {
		_g_free0 (preferences_ui_file);
		_g_object_unref0 (builder);
		goto __catch15_g_error;
	}
	gtk_builder_connect_signals (builder, NULL);
	_tmp2_ = gtk_builder_get_object (builder, "frame_metadata_appearance_settings");
	_tmp3_ = _tmp2_;
	_tmp4_ = _g_object_ref0 ((GtkWidget*) (GTK_IS_FRAME (_tmp3_) ? ((GtkFrame*) _tmp3_) : NULL));
	builderWidget = _tmp4_;
	gtk_container_add (container, builderWidget);
	gtk_widget_show_all (builderWidget);
	_tmp5_ = gtk_builder_get_object (builder, "checkbutton_show_lyrics");
	_tmp6_ = _tmp5_;
	_tmp7_ = _g_object_ref0 ((GtkWidget*) (GTK_IS_CHECK_BUTTON (_tmp6_) ? ((GtkCheckButton*) _tmp6_) : NULL));
	_g_object_unref0 (builderWidget);
	builderWidget = _tmp7_;
	_tmp8_ = cfg_get_single_value_as_int_with_default (config, "MetaData", "show-lyrics", 1);
	gtk_toggle_button_set_active ((GtkToggleButton*) GTK_CHECK_BUTTON (builderWidget), (gboolean) _tmp8_);
	_tmp9_ = gtk_builder_get_object (builder, "checkbutton_show_artist_information");
	_tmp10_ = _tmp9_;
	_tmp11_ = _g_object_ref0 ((GtkWidget*) (GTK_IS_CHECK_BUTTON (_tmp10_) ? ((GtkCheckButton*) _tmp10_) : NULL));
	_g_object_unref0 (builderWidget);
	builderWidget = _tmp11_;
	_tmp12_ = cfg_get_single_value_as_int_with_default (config, "MetaData", "show-artist-information", 1);
	gtk_toggle_button_set_active ((GtkToggleButton*) GTK_CHECK_BUTTON (builderWidget), (gboolean) _tmp12_);
	_tmp13_ = gtk_builder_get_object (builder, "checkbutton_show_web_links");
	_tmp14_ = _tmp13_;
	_tmp15_ = _g_object_ref0 ((GtkWidget*) (GTK_IS_CHECK_BUTTON (_tmp14_) ? ((GtkCheckButton*) _tmp14_) : NULL));
	_g_object_unref0 (builderWidget);
	builderWidget = _tmp15_;
	_tmp16_ = cfg_get_single_value_as_int_with_default (config, "MetaData", "show-web-links", 1);
	gtk_toggle_button_set_active ((GtkToggleButton*) GTK_CHECK_BUTTON (builderWidget), (gboolean) _tmp16_);
	_tmp17_ = gtk_builder_get_object (builder, "checkbutton_show_similar_artists");
	_tmp18_ = _tmp17_;
	_tmp19_ = _g_object_ref0 ((GtkWidget*) (GTK_IS_CHECK_BUTTON (_tmp18_) ? ((GtkCheckButton*) _tmp18_) : NULL));
	_g_object_unref0 (builderWidget);
	builderWidget = _tmp19_;
	_tmp20_ = cfg_get_single_value_as_int_with_default (config, "MetaData", "show-similar-artist", 1);
	gtk_toggle_button_set_active ((GtkToggleButton*) GTK_CHECK_BUTTON (builderWidget), (gboolean) _tmp20_);
	_tmp21_ = gtk_builder_get_object (builder, "checkbutton_show_similar_songs");
	_tmp22_ = _tmp21_;
	_tmp23_ = _g_object_ref0 ((GtkWidget*) (GTK_IS_CHECK_BUTTON (_tmp22_) ? ((GtkCheckButton*) _tmp22_) : NULL));
	_g_object_unref0 (builderWidget);
	builderWidget = _tmp23_;
	_tmp24_ = cfg_get_single_value_as_int_with_default (config, "MetaData", "show-similar-songs", 1);
	gtk_toggle_button_set_active ((GtkToggleButton*) GTK_CHECK_BUTTON (builderWidget), (gboolean) _tmp24_);
	_tmp25_ = gtk_builder_get_object (builder, "checkbutton_show_guitar_tabs");
	_tmp26_ = _tmp25_;
	_tmp27_ = _g_object_ref0 ((GtkWidget*) (GTK_IS_CHECK_BUTTON (_tmp26_) ? ((GtkCheckButton*) _tmp26_) : NULL));
	_g_object_unref0 (builderWidget);
	builderWidget = _tmp27_;
	_tmp28_ = cfg_get_single_value_as_int_with_default (config, "MetaData", "show-guitar-tabs", 1);
	gtk_toggle_button_set_active ((GtkToggleButton*) GTK_CHECK_BUTTON (builderWidget), (gboolean) _tmp28_);
	_g_object_unref0 (builderWidget);
	_g_free0 (preferences_ui_file);
	_g_object_unref0 (builder);
	goto __finally15;
	__catch15_g_error:
	{
		GError * e;
		e = _inner_error_;
		_inner_error_ = NULL;
		fprintf (stderr, "Could not load UI: %s\n", e->message);
		_g_error_free0 (e);
	}
	__finally15:
	if (_inner_error_ != NULL) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
		return;
	}
}
Beispiel #17
0
/** Connect one dialog widget to the appropriate callback function for
 *  its type.
 *
 *  @internal
 *
 *  @param name The name of the widget.
 *
 *  @param widget A pointer to the widget.
 *
 *  @param dialog A pointer to the dialog.
 */
static void
gnc_prefs_connect_one (const gchar *name,
                       GtkWidget *widget,
                       gpointer user_data)
{
    /* These tests must be ordered from more specific widget to less
     * specific widget. */

    if (GTK_IS_FONT_BUTTON(widget))
    {
        DEBUG("  %s - entry", name);
        gnc_prefs_connect_font_button(GTK_FONT_BUTTON(widget));
    }
    else if (GTK_IS_RADIO_BUTTON(widget))
    {
        DEBUG("  %s - radio button", name);
        gnc_prefs_connect_radio_button(GTK_RADIO_BUTTON(widget));
    }
    else if (GTK_IS_CHECK_BUTTON(widget))
    {
        DEBUG("  %s - check button", name);
        gnc_prefs_connect_check_button(GTK_CHECK_BUTTON(widget));
    }
    else if (GTK_IS_SPIN_BUTTON(widget))
    {
        DEBUG("  %s - spin button", name);
        gnc_prefs_connect_spin_button(GTK_SPIN_BUTTON(widget));
    }
    else if (GTK_IS_COMBO_BOX(widget))
    {
        DEBUG("  %s - combo box", name);
        gnc_prefs_connect_combo_box(GTK_COMBO_BOX(widget));
    }
    else if (GTK_IS_ENTRY(widget))
    {
        DEBUG("  %s - entry", name);
        gnc_prefs_connect_entry(GTK_ENTRY(widget));
    }
    else if (GTK_IS_HBOX(widget))
    {
        /* Test custom widgets are all children of a hbox */
        GtkWidget *widget_child;
        GList* child = gtk_container_get_children(GTK_CONTAINER(widget));
        widget_child = child->data;
        g_list_free(child);
        DEBUG("  %s - hbox", name);
        DEBUG("Hbox widget type is %s and name is %s", gtk_widget_get_name(GTK_WIDGET(widget_child)), name);

        if (GNC_IS_CURRENCY_EDIT(widget_child))
        {
            DEBUG("  %s - currency_edit", name);
            gnc_prefs_connect_currency_edit(GNC_CURRENCY_EDIT(widget_child), name );
        }
        else if (GNC_IS_PERIOD_SELECT(widget_child))
        {
            DEBUG("  %s - period_Select", name);
            gnc_prefs_connect_period_select(GNC_PERIOD_SELECT(widget_child), name );
        }
        else if (GNC_IS_DATE_EDIT(widget_child))
        {
            DEBUG("  %s - date_edit", name);
            gnc_prefs_connect_date_edit(GNC_DATE_EDIT(widget_child), name );
        }
    }
    else
    {
        DEBUG("  %s - unsupported %s", name,
              G_OBJECT_TYPE_NAME(G_OBJECT(widget)));
    }
}
void
e_kolab_folder_metadata_ui_update_from_uidata (KolabFolderMetaUIData *uidata)
{
	GtkWidget *widget = NULL;
	gulong handler_id = 0;
	guint ii = 0;

	g_return_if_fail (uidata != NULL);
	g_return_if_fail (E_IS_SHELL_VIEW (uidata->shell_view));
	g_return_if_fail (E_IS_ALERT_BAR (uidata->alert_bar));
	g_return_if_fail (uidata->metadata != NULL);
	g_return_if_fail (uidata->widgets != NULL);

	/* When updating the state of the UI here,
	 * we need to always make sure not to trigger
	 * signals which we may have handlers for.
	 * Updating the UI this way is meant to happen
	 * before the user actually uses it.
	 */

	/* radio button group (current folder type) */
	for (ii = 0; ii < KOLAB_FOLDER_META_UI_NUM_TYPES; ii++) {
		g_signal_handler_block (uidata->widgets->radio_btn_type[ii],
		                        uidata->widgets->radio_btn_handler_id[ii]);
	}

	switch (uidata->metadata->foldertype) {

	case KOLAB_FOLDER_TYPE_EVENT:
	case KOLAB_FOLDER_TYPE_EVENT_DEFAULT:
		ii = 1;
		break;

	case KOLAB_FOLDER_TYPE_NOTE:
	case KOLAB_FOLDER_TYPE_NOTE_DEFAULT:
		ii = 2;
		break;

	case KOLAB_FOLDER_TYPE_TASK:
	case KOLAB_FOLDER_TYPE_TASK_DEFAULT:
		ii = 3;
		break;

	case KOLAB_FOLDER_TYPE_CONTACT:
	case KOLAB_FOLDER_TYPE_CONTACT_DEFAULT:
		ii = 4;
		break;

	default:
		/* all else is regarded email */
		ii = 0;
	}

	widget = uidata->widgets->radio_btn_type[ii];
	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);

	for (ii = 0; ii < KOLAB_FOLDER_META_UI_NUM_TYPES; ii++) {
		g_signal_handler_unblock (uidata->widgets->radio_btn_type[ii],
		                          uidata->widgets->radio_btn_handler_id[ii]);
	}

	/* PIM options */

	/* option: sync conflict strategy */
	widget = uidata->widgets->cbox_syncstrategy;
	g_return_if_fail (GTK_IS_COMBO_BOX_TEXT (widget));
	handler_id = uidata->widgets->cbox_syncstrategy_id;
	g_signal_handler_block (widget, handler_id);
	gtk_combo_box_set_active (GTK_COMBO_BOX (widget),
	                          (gint) uidata->metadata->strategy);
	g_signal_handler_unblock (widget, handler_id);

	/* whether to show all PIM folders in email view */

	widget = uidata->widgets->chk_btn_show_all;
	g_return_if_fail (GTK_IS_CHECK_BUTTON (widget));
	handler_id = uidata->widgets->chk_btn_show_all_handler_id;

	g_signal_handler_block (widget, handler_id);
	if (uidata->metadata->show_all)
		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget),
		                              TRUE);
	else
		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget),
		                              FALSE);
	g_signal_handler_unblock (widget, handler_id);
}
Beispiel #19
0
GtkWidget*
stpui_slider_new (stp_vars_t *vars,const char *optname,GtkWidget *checkbutton)
{
	stp_parameter_t desc;
	double step=1.0;
	stpui_Slider *c=STPUI_SLIDER(g_object_new (stpui_slider_get_type (), NULL));
	gboolean active=FALSE;

	c->vars=vars;
	c->optionname=optname;
	c->checkbutton=NULL;
	c->label=NULL;
	if(GTK_IS_CHECK_BUTTON(checkbutton))
		c->checkbutton=GTK_CHECK_BUTTON(checkbutton);
	else
		c->label=checkbutton;

	stp_describe_parameter(c->vars,c->optionname,&desc);
	c->type=desc.p_type;

	switch(c->type)
	{
		case STP_PARAMETER_TYPE_DOUBLE:
			active=stp_check_float_parameter(c->vars,c->optionname,STP_PARAMETER_DEFAULTED);
			step=0.01;
			break;
		case STP_PARAMETER_TYPE_INT:
			active=stp_check_int_parameter(c->vars,c->optionname,STP_PARAMETER_DEFAULTED);
			step=1.0;
			break;
		case STP_PARAMETER_TYPE_DIMENSION:
			active=stp_check_dimension_parameter(c->vars,c->optionname,STP_PARAMETER_DEFAULTED);
			step=1.0;
			break;
		default:
			break;
	}
	stp_parameter_description_destroy(&desc);

	if(c->checkbutton)
	{
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(c->checkbutton),active);
		g_signal_connect(G_OBJECT(c->checkbutton),"toggled",G_CALLBACK(stpui_toggle_changed),c);
	}

	c->scale=gtk_hscale_new_with_range(0,1.0,step);
	gtk_scale_set_draw_value(GTK_SCALE(c->scale),FALSE);
	
	switch(desc.p_type)
	{
		case STP_PARAMETER_TYPE_DOUBLE:
		case STP_PARAMETER_TYPE_INT:
			c->spin=gtk_spin_button_new_with_range(0,1.0,step);
			break;
		case STP_PARAMETER_TYPE_DIMENSION:
			c->spin=dimension_new(0,1.0,UNIT_POINTS);
			dimension_show_unit(DIMENSION(c->spin));
			break;
		default:
			break;
	}
	
	g_signal_connect(GTK_WIDGET(c->scale),"button-release-event",G_CALLBACK(stpui_slider_released),c);
	g_signal_connect(GTK_WIDGET(c->spin),"button-release-event",G_CALLBACK(stpui_spin_released),c);
	g_signal_connect(GTK_WIDGET(c->scale),"value-changed",G_CALLBACK(stpui_slider_changed),c);
	g_signal_connect(GTK_WIDGET(c->spin),"value-changed",G_CALLBACK(stpui_spin_changed),c);

	stpui_slider_refresh(c);

	gtk_box_pack_start(GTK_BOX(c),GTK_WIDGET(c->scale),TRUE,TRUE,0);
	gtk_widget_show(c->scale);

	gtk_box_pack_start(GTK_BOX(c),GTK_WIDGET(c->spin),FALSE,TRUE,0);
	gtk_widget_show(c->spin);
	
	return(GTK_WIDGET(c));
}