コード例 #1
0
ファイル: gtkswitch.c プロジェクト: BYC/gtk
static void
gtk_switch_get_property (GObject    *gobject,
                         guint       prop_id,
                         GValue     *value,
                         GParamSpec *pspec)
{
  GtkSwitchPrivate *priv = GTK_SWITCH (gobject)->priv;

  switch (prop_id)
    {
    case PROP_ACTIVE:
      g_value_set_boolean (value, priv->is_active);
      break;

    case PROP_RELATED_ACTION:
      g_value_set_object (value, priv->action);
      break;

    case PROP_USE_ACTION_APPEARANCE:
      g_value_set_boolean (value, priv->use_action_appearance);
      break;

    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
    }
}
コード例 #2
0
GPInstructLessonTestMultiChoiceEditor *
gpinstruct_lesson_test_multi_choice_editor_new (GPInstructEditorWindow *window,
                                                GPInstructLessonTestMultiChoice *test)
{
	GPInstructLessonTestMultiChoiceEditor *editor = g_object_new (GPINSTRUCT_TYPE_LESSON_TEST_MULTI_CHOICE_EDITOR, NULL);
	GPInstructLessonTestMultiChoiceEditorPrivate *priv = editor->priv;

	priv->window = window;
	priv->test = test;

	gtk_entry_set_text (GTK_ENTRY (priv->title_entry),
	                    gpinstruct_lesson_element_get_title (GPINSTRUCT_LESSON_ELEMENT (test)));
	g_signal_connect (priv->title_entry, "activate",
	                  G_CALLBACK (title_entry_activate), editor);

	GtkTextBuffer *buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (priv->directions_view));
	gtk_text_buffer_set_text (buffer,
	                          gpinstruct_lesson_test_get_directions (GPINSTRUCT_LESSON_TEST (test)), -1);
	g_signal_connect (buffer, "changed",
	                  G_CALLBACK (directions_buffer_changed), editor);

	gtk_switch_set_active (GTK_SWITCH (priv->explain_switch),
	                       gpinstruct_lesson_test_get_explain (GPINSTRUCT_LESSON_TEST (test)));
	g_signal_connect (priv->explain_switch, "notify::active",
	                  G_CALLBACK (explain_activate), editor);

	update_questions_tree_view (editor);

	return editor;
}
コード例 #3
0
ファイル: gtkswitch.c プロジェクト: BYC/gtk
static void
gtk_switch_set_property (GObject      *gobject,
                         guint         prop_id,
                         const GValue *value,
                         GParamSpec   *pspec)
{
  GtkSwitch *sw = GTK_SWITCH (gobject);

  switch (prop_id)
    {
    case PROP_ACTIVE:
      gtk_switch_set_active (sw, g_value_get_boolean (value));
      break;

    case PROP_RELATED_ACTION:
      gtk_switch_set_related_action (sw, g_value_get_object (value));
      break;

    case PROP_USE_ACTION_APPEARANCE:
      gtk_switch_set_use_action_appearance (sw, g_value_get_boolean (value));
      break;

    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
    }
}
コード例 #4
0
static inline void
gtk_switch_paint_handle (GtkWidget    *widget,
                         cairo_t      *cr,
                         GdkRectangle *box)
{
  GtkSwitchPrivate *priv = GTK_SWITCH (widget)->priv;
  GtkStyleContext *context = gtk_widget_get_style_context (widget);
  GtkStateFlags state;

  state = gtk_widget_get_state_flags (widget);

  if (priv->is_active)
    state |= GTK_STATE_FLAG_ACTIVE;

  gtk_style_context_save (context);
  gtk_style_context_set_state (context, state);
  gtk_style_context_add_class (context, GTK_STYLE_CLASS_SLIDER);

  gtk_render_slider (context, cr,
                     box->x, box->y,
                     box->width, box->height,
                     GTK_ORIENTATION_HORIZONTAL);

  gtk_style_context_restore (context);
}
コード例 #5
0
static gboolean
cc_sharing_panel_switch_to_label_transform_func (GBinding       *binding,
                                                 const GValue   *source_value,
                                                 GValue         *target_value,
                                                 CcSharingPanel *self)
{
  gboolean active;

  if (!G_VALUE_HOLDS_BOOLEAN (source_value))
    return FALSE;

  if (!G_VALUE_HOLDS_STRING (target_value))
    return FALSE;

  active = g_value_get_boolean (source_value);

  if (active)
    g_value_set_string (target_value, C_("service is enabled", "On"));
  else
    g_value_set_string (target_value, C_("service is disabled", "Off"));

  /* ensure the master switch is active if one of the services is active */
  if (active)
    gtk_switch_set_active (GTK_SWITCH (self->priv->master_switch), TRUE);

  return TRUE;
}
コード例 #6
0
static GtkWidget *
make_switch (gboolean is_on,
             gboolean is_sensitive)
{
  GtkWidget *hbox;
  GtkWidget *sw, *label;

  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);

  sw = gtk_switch_new ();
  gtk_switch_set_active (GTK_SWITCH (sw), is_on);
  gtk_box_pack_start (GTK_BOX (hbox), sw, FALSE, FALSE);
  gtk_widget_set_sensitive (sw, is_sensitive);
  gtk_widget_show (sw);

  label = gtk_label_new (is_on ? "Enabled" : "Disabled");
  gtk_box_pack_end (GTK_BOX (hbox), label, TRUE, TRUE);
  gtk_widget_show (label);

  g_object_bind_property_full (sw, "active",
                               label, "label",
                               G_BINDING_DEFAULT,
                               boolean_to_text,
                               NULL,
                               NULL, NULL);

  return hbox;
}
コード例 #7
0
ファイル: nimf-settings.c プロジェクト: wcho/nimf
static GtkWidget *
nimf_settings_page_key_build_boolean (NimfSettingsPageKey *page_key)
{
  GtkWidget *gswitch;
  GtkWidget *hbox;
  gchar     *detailed_signal;
  gboolean   is_active;

  gswitch = gtk_switch_new ();
  is_active = g_settings_get_boolean (page_key->gsettings, page_key->key);
  gtk_switch_set_active (GTK_SWITCH (gswitch), is_active);
  gtk_widget_set_halign  (gswitch, GTK_ALIGN_END);
  detailed_signal = g_strdup_printf ("changed::%s", page_key->key);

  g_signal_connect (gswitch, "notify::active",
                    G_CALLBACK (on_notify_active), page_key);
  g_signal_connect (page_key->gsettings, detailed_signal,
                    G_CALLBACK (on_gsettings_changed), gswitch);

  g_free (detailed_signal);

  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 15);
  gtk_box_pack_start (GTK_BOX (hbox), page_key->label, FALSE, FALSE, 0);
  gtk_box_pack_end   (GTK_BOX (hbox), gswitch, FALSE, FALSE, 0);

  return hbox;
}
コード例 #8
0
static void
device_ethernet_refresh_ui (NetDeviceEthernet *device)
{
        NMDevice *nm_device;
        NMDeviceState state;
        GtkWidget *widget;
        gchar *speed = NULL;

        nm_device = net_device_get_nm_device (NET_DEVICE (device));

        widget = GTK_WIDGET (gtk_builder_get_object (device->builder, "label_device"));
        gtk_label_set_label (GTK_LABEL (widget), net_object_get_title (NET_OBJECT (device)));

        widget = GTK_WIDGET (gtk_builder_get_object (device->builder, "image_device"));
        gtk_image_set_from_icon_name (GTK_IMAGE (widget),
                                      panel_device_to_icon_name (nm_device, FALSE),
                                      GTK_ICON_SIZE_DIALOG);

        widget = GTK_WIDGET (gtk_builder_get_object (device->builder, "device_off_switch"));
        state = nm_device_get_state (nm_device);
        gtk_widget_set_visible (widget,
                                state != NM_DEVICE_STATE_UNAVAILABLE
                                && state != NM_DEVICE_STATE_UNMANAGED);
        device->updating_device = TRUE;
        gtk_switch_set_active (GTK_SWITCH (widget), device_state_to_off_switch (state));
        device->updating_device = FALSE;

        if (state != NM_DEVICE_STATE_UNAVAILABLE)
                speed = net_device_simple_get_speed (NET_DEVICE_SIMPLE (device));
        panel_set_device_status (device->builder, "label_status", nm_device, speed);

        populate_ui (device);
}
コード例 #9
0
static void
on_perm_store_set_done (GObject *source_object,
                        GAsyncResult *res,
                        gpointer user_data)
{
  LocationAppStateData *data;
  GVariant *results;
  GError *error = NULL;

  results = g_dbus_proxy_call_finish (G_DBUS_PROXY (source_object),
                                      res,
                                      &error);
  if (results == NULL)
    {
      if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
        g_warning ("Failed to store permissions: %s", error->message);
      g_error_free (error);

      return;
    }
  g_variant_unref (results);

  data = (LocationAppStateData *) user_data;
  data->changing_state = FALSE;
  gtk_switch_set_state (GTK_SWITCH (data->widget), data->pending_state);
}
コード例 #10
0
static void
autologin_changed (GObject            *object,
                   GParamSpec         *pspec,
                   UmUserPanelPrivate *d)
{
        gboolean active;
        UmUser *user;

        active = gtk_switch_get_active (GTK_SWITCH (object));
        user = get_selected_user (d);

        if (active != um_user_get_automatic_login (user)) {
                um_user_set_automatic_login (user, active);
                if (um_user_get_automatic_login (user)) {
                        GSList *list;
                        GSList *l;
                        list = um_user_manager_list_users (d->um);
                        for (l = list; l != NULL; l = l->next) {
                                UmUser *u = l->data;
                                if (um_user_get_uid (u) != um_user_get_uid (user)) {
                                        um_user_set_automatic_login (user, FALSE);
                                }
                        }
                        g_slist_free (list);
                }
        }

        g_object_unref (user);
}
コード例 #11
0
ファイル: gtkswitch.c プロジェクト: BYC/gtk
static gboolean
gtk_switch_key_release (GtkWidget   *widget,
                        GdkEventKey *event)
{
  GtkSwitchPrivate *priv = GTK_SWITCH (widget)->priv;

  if (event->keyval == GDK_KEY_Return ||
      event->keyval == GDK_KEY_KP_Enter ||
      event->keyval == GDK_KEY_ISO_Enter ||
      event->keyval == GDK_KEY_space ||
      event->keyval == GDK_KEY_KP_Space)
    {
      gtk_switch_set_active (GTK_SWITCH (widget), !priv->is_active);
    }

  return FALSE;
}
コード例 #12
0
ファイル: nimf-settings.c プロジェクト: inureyes/nimf
static void
on_gsettings_changed (GSettings *settings,
                      gchar     *key,
                      GtkWidget *widget)
{
  if (GTK_IS_SWITCH (widget))
  {
    gboolean active1 = g_settings_get_boolean (settings, key);
    gboolean active2 = gtk_switch_get_active (GTK_SWITCH (widget));

    if (active1 != active2)
      gtk_switch_set_active (GTK_SWITCH (widget), active1);
  }
  else if (GTK_IS_COMBO_BOX (widget))
  {
    gchar    *id;
    gboolean  retval;

    id = g_settings_get_string (settings, key);
    retval = gtk_combo_box_set_active_id (GTK_COMBO_BOX (widget), id);

    if (retval == FALSE && g_strcmp0 (key, "default-engine") == 0)
      g_settings_set_string (settings, key, "nimf-system-keyboard");

    g_free (id);
  }
  else if (GTK_IS_TREE_VIEW (widget))
  {
    GtkTreeModel  *model;
    gchar        **vals;
    GtkTreeIter    iter;
    gint           i;

    vals = g_settings_get_strv (settings, key);
    model = gtk_tree_view_get_model (GTK_TREE_VIEW (widget));
    gtk_list_store_clear (GTK_LIST_STORE (model));

    for (i = 0; vals[i] != NULL; i++)
    {
      gtk_list_store_append (GTK_LIST_STORE (model), &iter);
      gtk_list_store_set    (GTK_LIST_STORE (model), &iter, 0, vals[i], -1);
    }

    g_strfreev (vals);
  }
}
コード例 #13
0
static void
change_ntp (GObject         *gobject,
            GParamSpec      *pspec,
            CcDateTimePanel *self)
{
  update_widget_state_for_ntp (self, gtk_switch_get_active (GTK_SWITCH (gobject)));
  queue_set_ntp (self);
}
コード例 #14
0
ファイル: keybinds.c プロジェクト: BucketPW/pomfit
void keybinds_conf_save (void) {

	int i;
	int Mod1[HOTKEY_COUNT], Mod2[HOTKEY_COUNT] , Key[HOTKEY_COUNT];
	char sMods[5][10] = { "" , "<CTRL>", "<SHIFT>", "<ALT>", "<WIN>" };
	char ConfFilePath [512];
	FILE *fpConfig = NULL;
	#ifdef __linux__
	sprintf(ConfFilePath ,"%s/keybinds.ini" ,DirConf);
	#elif __WIN32
	sprintf(ConfFilePath ,"%s\\keybinds.ini" ,DirConf);
	#endif
	fpConfig = fopen(ConfFilePath , "w");
	if (fpConfig == NULL) {
		log_error(true,"***Error: Couldn't write to config file 'keybinds.ini'");
		return;
	}

	for ( i = 0 ; i < HOTKEY_COUNT ; ++i) {
		Mod1[i] = gtk_combo_box_get_active(GTK_COMBO_BOX(com_kb_mod1[i]));
		Mod2[i] = gtk_combo_box_get_active(GTK_COMBO_BOX(com_kb_mod2[i]));
		Key[i] = gtk_combo_box_get_active(GTK_COMBO_BOX(com_kb_key[i]));

	}

	fprintf(fpConfig, "Hotkey_FUP = %s%s%c\n",
		Mod1[0] != Mod2[0] ? sMods[Mod1[0]] : "" , sMods[Mod2[0]], Key[0]+33);
	fprintf(fpConfig, "Hotkey_SS_A_UP = %s%s%c\n",
		Mod1[1] != Mod2[1] ? sMods[Mod1[1]] : "" , sMods[Mod2[1]], Key[1]+33);
	fprintf(fpConfig, "Hotkey_SS_W_UP = %s%s%c\n",
		Mod1[2] != Mod2[2] ? sMods[Mod1[2]] : "" , sMods[Mod2[2]], Key[2]+33);
	fprintf(fpConfig, "Hotkey_SS_F_UP = %s%s%c\n",
		Mod1[3] != Mod2[3] ? sMods[Mod1[3]] : "" , sMods[Mod2[3]], Key[3]+33);
    fprintf(fpConfig, "Hotkey_SS_A_CAP = %s%s%c\n",
		Mod1[4] != Mod2[4] ? sMods[Mod1[4]] : "" , sMods[Mod2[4]], Key[4]+33);
	fprintf(fpConfig, "Hotkey_SS_W_CAP = %s%s%c\n",
		Mod1[5] != Mod2[5] ? sMods[Mod1[5]] : "" , sMods[Mod2[5]], Key[5]+33);
	fprintf(fpConfig, "Hotkey_SS_F_CAP = %s%s%c\n",
		Mod1[6] != Mod2[6] ? sMods[Mod1[6]] : "" , sMods[Mod2[6]], Key[6]+33);
	fprintf(fpConfig, "Hotkey_OPEN = %s%s%c\n",
		Mod1[7] != Mod2[7] ? sMods[Mod1[7]] : "" , sMods[Mod2[7]], Key[7]+33);
	fprintf(fpConfig, "Enable_HK_FUP = %d\n", gtk_switch_get_active (GTK_SWITCH(sw_kb[0])));
	fprintf(fpConfig, "Enable_HK_SS_A_UP = %d\n", gtk_switch_get_active (GTK_SWITCH(sw_kb[1])));
	fprintf(fpConfig, "Enable_HK_SS_W_UP = %d\n", gtk_switch_get_active (GTK_SWITCH(sw_kb[2])));
	fprintf(fpConfig, "Enable_HK_SS_F_UP = %d\n",gtk_switch_get_active (GTK_SWITCH(sw_kb[3])));
	fprintf(fpConfig, "Enable_HK_SS_A_CAP = %d\n", gtk_switch_get_active (GTK_SWITCH(sw_kb[4])));
	fprintf(fpConfig, "Enable_HK_SS_W_CAP = %d\n", gtk_switch_get_active (GTK_SWITCH(sw_kb[5])));
	fprintf(fpConfig, "Enable_HK_SS_F_CAP = %d\n", gtk_switch_get_active (GTK_SWITCH(sw_kb[6])));
	fprintf(fpConfig, "Enable_HK_OPEN = %d\n",gtk_switch_get_active (GTK_SWITCH(sw_kb[7])));

	fclose(fpConfig);

	keybinds_window_destroy();
	keybinds_conf_load();
}
コード例 #15
0
ファイル: gtkswitch.c プロジェクト: 3dfxmadscientist/gtk
static gboolean
gtk_switch_motion (GtkWidget      *widget,
                   GdkEventMotion *event)
{
  GtkSwitchPrivate *priv = GTK_SWITCH (widget)->priv;

  /* if this is a direct toggle we don't handle motion */
  if (priv->in_press)
    return GDK_EVENT_PROPAGATE;

  if (ABS (event->x - priv->drag_start) < priv->drag_threshold)
    return GDK_EVENT_STOP;

  if (event->state & GDK_BUTTON1_MASK)
    {
      gint position = event->x - priv->offset;
      GtkAllocation allocation;
      GtkStyleContext *context;
      GtkStateFlags state;
      GtkBorder padding;
      gint width, focus_width, focus_pad;

      gtk_widget_style_get (widget,
                            "focus-line-width", &focus_width,
                            "focus-padding", &focus_pad,
                            NULL);

      context = gtk_widget_get_style_context (widget);
      state = gtk_widget_get_state_flags (widget);

      gtk_style_context_save (context);
      gtk_style_context_add_class (context, GTK_STYLE_CLASS_SLIDER);
      gtk_style_context_get_padding (context, state, &padding);
      gtk_style_context_restore (context);
      
      gtk_widget_get_allocation (widget, &allocation);

      width = allocation.width - 2 * (focus_width + focus_pad);

      /* constrain the handle within the trough width */
      if (position > (width / 2) - padding.right)
        priv->handle_x = width / 2 - padding.right;
      else if (position < padding.left)
        priv->handle_x = 0;
      else
        priv->handle_x = position;

      priv->is_dragging = TRUE;

      /* we need to redraw the handle */
      gtk_widget_queue_draw (widget);

      return GDK_EVENT_STOP;
    }

  return GDK_EVENT_PROPAGATE;
}
コード例 #16
0
static void
gtk_switch_unmap (GtkWidget *widget)
{
  GtkSwitchPrivate *priv = GTK_SWITCH (widget)->priv;

  if (priv->event_window)
    gdk_window_hide (priv->event_window);

  GTK_WIDGET_CLASS (gtk_switch_parent_class)->unmap (widget);
}
コード例 #17
0
static void
gtk_switch_get_preferred_height (GtkWidget *widget,
                                 gint      *minimum,
                                 gint      *natural)
{
  GtkSwitchPrivate *priv = GTK_SWITCH (widget)->priv;
  GtkStyleContext *context;
  GtkStateFlags state;
  GtkBorder padding;
  gint height, focus_width, focus_pad;
  PangoLayout *layout;
  PangoRectangle logical_rect;
  gchar *str;

  context = gtk_widget_get_style_context (widget);
  state = gtk_widget_get_state_flags (widget);

  if (priv->is_active)
    state |= GTK_STATE_FLAG_ACTIVE;

  gtk_style_context_save (context);

  gtk_style_context_set_state (context, state);
  gtk_style_context_add_class (context, GTK_STYLE_CLASS_SLIDER);
  gtk_style_context_get_padding (context, state, &padding);

  height = padding.top + padding.bottom;

  gtk_style_context_restore (context);

  gtk_widget_style_get (widget,
                        "focus-line-width", &focus_width,
                        "focus-padding", &focus_pad,
                        NULL);

  height += 2 * (focus_width + focus_pad);

  str = g_strdup_printf ("%s%s",
                         C_("switch", "ON"),
                         C_("switch", "OFF"));

  layout = gtk_widget_create_pango_layout (widget, str);
  pango_layout_get_extents (layout, NULL, &logical_rect);
  pango_extents_to_pixels (&logical_rect, NULL);
  height += MAX (DEFAULT_SLIDER_HEIGHT, logical_rect.height);

  g_object_unref (layout);
  g_free (str);

  if (minimum)
    *minimum = height;

  if (natural)
    *natural = height;
}
コード例 #18
0
ファイル: nemo-share.c プロジェクト: Fantu/nemo-extensions
static gboolean
property_page_commit (PropertyPage *page)
{
  gboolean is_shared;
  ShareInfo share_info;
  ConfirmPermissionsStatus status;
  GError *error;
  gboolean retval;

  is_shared = gtk_switch_get_active (GTK_SWITCH (page->switch_share_folder));

  share_info.path = page->path;
  share_info.share_name = (char *) gtk_entry_get_text (GTK_ENTRY (page->entry_share_name));
  share_info.comment = (char *) gtk_entry_get_text (GTK_ENTRY (page->entry_share_comment));
  share_info.is_writable = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (page->checkbutton_share_rw_ro));
  share_info.guest_ok = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (page->checkbutton_share_guest_ok));

  /* Do we need to unset the write permissions that we added in the past? */
  if (is_shared && page->was_writable && !share_info.is_writable)
    restore_write_permissions (page->path);

  status = confirm_sharing_permissions (page->main, page->path, is_shared, share_info.guest_ok, share_info.is_writable);
  if (status == CONFIRM_CANCEL_OR_ERROR)
    return FALSE; /* the user didn't want us to change his folder's permissions */

  error = NULL;
  retval = shares_modify_share (share_info.path, is_shared ? &share_info : NULL, &error);

  if (!retval)
    {
      property_page_set_error (page, error->message);
      g_error_free (error);

      /* Since the operation failed, we restore things to the way they were */
      if (status == CONFIRM_MODIFIED)
	restore_saved_permissions (page->path);
    }
  else
    {
      property_page_validate_fields (page);
      nemo_file_info_invalidate_extension_info (page->fileinfo);
    }

  if (!is_shared)
    restore_saved_permissions (page->path);

  /* update initially shared state, so that we may undo later on */
  if (retval)
    {
      page->was_initially_shared = is_shared;
      page->is_dirty = FALSE;
    }

  return retval;
}
コード例 #19
0
static void
gtk_switch_set_action_target_value (GtkActionable *actionable,
                                    GVariant      *action_target)
{
  GtkSwitch *sw = GTK_SWITCH (actionable);

  if (!sw->priv->action_helper)
    sw->priv->action_helper = gtk_action_helper_new (actionable);

  gtk_action_helper_set_action_target_value (sw->priv->action_helper, action_target);
}
コード例 #20
0
ファイル: gtkswitch.c プロジェクト: 3dfxmadscientist/gtk
static gboolean
gtk_switch_leave (GtkWidget        *widget,
                  GdkEventCrossing *event)
{
  GtkSwitchPrivate *priv = GTK_SWITCH (widget)->priv;

  if (event->window == priv->event_window)
    priv->in_switch = FALSE;

  return FALSE;
}
コード例 #21
0
static void
gtk_switch_set_action_name (GtkActionable *actionable,
                            const gchar   *action_name)
{
  GtkSwitch *sw = GTK_SWITCH (actionable);

  if (!sw->priv->action_helper)
    sw->priv->action_helper = gtk_action_helper_new (actionable);

  gtk_action_helper_set_action_name (sw->priv->action_helper, action_name);
}
コード例 #22
0
ファイル: flashlight.c プロジェクト: DeforaOS/Flashlight
/* flashlight_set_active */
void flashlight_set_active(Flashlight * flashlight, gboolean active)
{
	flashlightbackend_set(active);
	gtk_widget_set_sensitive(flashlight->image, active);
#if GTK_CHECK_VERSION(3, 0, 0)
	gtk_switch_set_active(GTK_SWITCH(flashlight->co_toggle), active);
#else
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(flashlight->co_toggle),
			active);
#endif
}
コード例 #23
0
ファイル: flashlight.c プロジェクト: DeforaOS/Flashlight
/* flashlight_on_toggled */
static void _flashlight_on_toggled(gpointer data)
{
	Flashlight * flashlight = data;

#if GTK_CHECK_VERSION(3, 0, 0)
	flashlight_set_active(flashlight, gtk_switch_get_active(
				GTK_SWITCH(flashlight->co_toggle)));
#else
	flashlight_set_active(flashlight, gtk_toggle_button_get_active(
				GTK_TOGGLE_BUTTON(flashlight->co_toggle)));
#endif
}
コード例 #24
0
static void
aspectswitch_toggled_cb (GtkWidget           *widget,
                         GParamSpec          *pspec,
			 CcWacomMappingPanel *self)
{
	GSettings *settings;

	settings = gsd_wacom_device_get_settings (self->priv->device);
	g_settings_set_boolean (settings,
				"keep-aspect",
				gtk_switch_get_active (GTK_SWITCH (widget)));
}
コード例 #25
0
static void
checkbutton_toggled_cb (GtkWidget           *widget,
			CcWacomMappingPanel *self)
{
	gboolean active;

	active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
	set_combobox_sensitive (self, active);
	if (!active)
		gtk_switch_set_active (GTK_SWITCH(self->priv->aspectswitch), FALSE);
	update_mapping (self);
}
コード例 #26
0
static void
setup_touchpad_options (CcMousePropertiesPrivate *d)
{
	gboolean edge_scroll_enabled;
	gboolean two_finger_scroll_enabled;
	gboolean have_two_finger_scrolling;
	gboolean have_edge_scrolling;
	gboolean have_tap_to_click;

	gtk_widget_set_visible (WID ("touchpad-frame"), !d->have_synaptics);
	if (d->have_synaptics)
		return;

	gtk_widget_set_visible (WID ("touchpad-frame"), d->have_touchpad);
	if (!d->have_touchpad)
		return;

	cc_touchpad_check_capabilities (&have_two_finger_scrolling, &have_edge_scrolling, &have_tap_to_click);

	gtk_widget_show_all (WID ("touchpad-frame"));

	gtk_widget_set_visible (WID ("two-finger-scrolling-row"), have_two_finger_scrolling);
	gtk_widget_set_visible (WID ("edge-scrolling-row"), have_edge_scrolling);
	gtk_widget_set_visible (WID ("tap-to-click-row"), have_tap_to_click);

	edge_scroll_enabled = g_settings_get_boolean (d->touchpad_settings, "edge-scrolling-enabled");
	two_finger_scroll_enabled = g_settings_get_boolean (d->touchpad_settings, "two-finger-scrolling-enabled");
	if (edge_scroll_enabled && two_finger_scroll_enabled) {
		/* You cunning user set both, but you can only have one set in that UI */
		d->changing_scroll = TRUE;
		gtk_switch_set_active (GTK_SWITCH (WID ("two-finger-scrolling-switch")), two_finger_scroll_enabled);
		d->changing_scroll = FALSE;
		gtk_switch_set_active (GTK_SWITCH (WID ("edge-scrolling-switch")), FALSE);
	} else {
		d->changing_scroll = TRUE;
		gtk_switch_set_active (GTK_SWITCH (WID ("edge-scrolling-switch")), edge_scroll_enabled);
		gtk_switch_set_active (GTK_SWITCH (WID ("two-finger-scrolling-switch")), two_finger_scroll_enabled);
		d->changing_scroll = FALSE;
	}
}
コード例 #27
0
static void
set_left_handed_from_gsettings (CcWacomPage *page)
{
	CcWacomPagePrivate	*priv = CC_WACOM_PAGE(page)->priv;
	CsdWacomDevice          *device = priv->stylus;
	CsdWacomRotation 	display_rotation;
	const gchar*		rotation;

	display_rotation = csd_wacom_device_get_display_rotation (device);
	rotation = g_settings_get_string (priv->wacom_settings, "rotation");
	if (strcmp (rotation, csd_wacom_device_rotation_type_to_name (display_rotation)) != 0)
		gtk_switch_set_active (GTK_SWITCH (WID ("switch-left-handed")), TRUE);
}
コード例 #28
0
static void
gtk_switch_dispose (GObject *object)
{
  GtkSwitchPrivate *priv = GTK_SWITCH (object)->priv;

  if (priv->action)
    {
      gtk_activatable_do_set_related_action (GTK_ACTIVATABLE (object), NULL);
      priv->action = NULL;
    }

  G_OBJECT_CLASS (gtk_switch_parent_class)->dispose (object);
}
コード例 #29
0
static void
add_routes_section (CEPageIP4 *page)
{
        GtkWidget *widget;
        GtkWidget *frame;
        GtkWidget *list;
        gint i;

        widget = GTK_WIDGET (gtk_builder_get_object (CE_PAGE (page)->builder, "routes_section"));

        frame = gtk_frame_new (NULL);
        gtk_container_add (GTK_CONTAINER (widget), frame);
        page->routes_list = list = gtk_list_box_new ();
        gtk_list_box_set_selection_mode (GTK_LIST_BOX (list), GTK_SELECTION_NONE);
        gtk_list_box_set_header_func (GTK_LIST_BOX (list), cc_list_box_update_header_func, NULL, NULL);
        gtk_list_box_set_sort_func (GTK_LIST_BOX (list), (GtkListBoxSortFunc)sort_first_last, NULL, NULL);
        gtk_container_add (GTK_CONTAINER (frame), list);
        page->auto_routes = GTK_SWITCH (gtk_builder_get_object (CE_PAGE (page)->builder, "auto_routes_switch"));
        gtk_switch_set_active (page->auto_routes, !nm_setting_ip4_config_get_ignore_auto_routes (page->setting));
        g_signal_connect (page->auto_routes, "notify::active", G_CALLBACK (switch_toggled), page);

        add_section_toolbar (page, widget, G_CALLBACK (add_empty_route_row));

        for (i = 0; i < nm_setting_ip4_config_get_num_routes (page->setting); i++) {
                NMIP4Route *route;
                struct in_addr tmp_addr;
                gchar address[INET_ADDRSTRLEN + 1];
                gchar netmask[INET_ADDRSTRLEN + 1];
                gchar gateway[INET_ADDRSTRLEN + 1];
                gint metric;

                route = nm_setting_ip4_config_get_route (page->setting, i);
                if (!route)
                        continue;

                tmp_addr.s_addr = nm_ip4_route_get_dest (route);
                (void) inet_ntop (AF_INET, &tmp_addr, &address[0], sizeof (address));

                tmp_addr.s_addr = nm_utils_ip4_prefix_to_netmask (nm_ip4_route_get_prefix (route));
                (void) inet_ntop (AF_INET, &tmp_addr, &netmask[0], sizeof (netmask));

                tmp_addr.s_addr = nm_ip4_route_get_next_hop (route);
                (void) inet_ntop (AF_INET, &tmp_addr, &gateway[0], sizeof (gateway));
                metric = nm_ip4_route_get_metric (route);
                add_route_row (page, address, netmask, gateway, metric);
        }
        if (nm_setting_ip4_config_get_num_routes (page->setting) == 0)
                add_empty_route_row (page);

        gtk_widget_show_all (widget);
}
コード例 #30
0
static void
cc_bluetooth_panel_update_power (CcBluetoothPanel *self)
{
	GObject *toggle;
	gboolean sensitive, powered, change_powered;
	const char *page;

	g_debug ("Updating airplane mode: has_airplane_mode %d, hardware_airplane_mode %d, BT airplane_mode %d, airplane_mode %d",
		 self->priv->has_airplane_mode, self->priv->hardware_airplane_mode, self->priv->bt_airplane_mode, self->priv->airplane_mode);

	change_powered = TRUE;

	if (self->priv->has_airplane_mode == FALSE) {
		g_debug ("No Bluetooth available");
		sensitive = FALSE;
		powered = FALSE;
		page = BLUETOOTH_NO_DEVICES_PAGE;
	} else if (self->priv->hardware_airplane_mode) {
		g_debug ("Bluetooth is Hard blocked");
		sensitive = FALSE;
		powered = FALSE;
		page = BLUETOOTH_HW_AIRPLANE_PAGE;
	} else if (self->priv->airplane_mode) {
		g_debug ("Airplane mode is on, Wi-Fi and Bluetooth are disabled");
		sensitive = FALSE;
		powered = FALSE;
		page = BLUETOOTH_AIRPLANE_PAGE;
	} else if (self->priv->bt_airplane_mode ||
		   !bluetooth_settings_widget_get_default_adapter_powered (BLUETOOTH_SETTINGS_WIDGET (self->priv->widget))) {
		g_debug ("Default adapter is unpowered, but should be available");
		sensitive = TRUE;
		change_powered = FALSE;
		page = BLUETOOTH_DISABLED_PAGE;
	} else {
		g_debug ("Bluetooth is available and powered");
		sensitive = TRUE;
		powered = TRUE;
		page = BLUETOOTH_WORKING_PAGE;
	}

	gtk_widget_set_sensitive (WID ("box_power") , sensitive);

	toggle = G_OBJECT (WID ("switch_bluetooth"));
	if (change_powered) {
		g_signal_handlers_block_by_func (toggle, power_callback, self);
		gtk_switch_set_active (GTK_SWITCH (toggle), powered);
		g_signal_handlers_unblock_by_func (toggle, power_callback, self);
	}

	gtk_stack_set_visible_child_name (GTK_STACK (self->priv->stack), page);
}