Exemple #1
0
static gboolean
gtk_switch_button_release (GtkWidget      *widget,
                           GdkEventButton *event)
{
  GtkSwitchPrivate *priv = GTK_SWITCH (widget)->priv;
  GtkAllocation allocation;

  gtk_widget_get_allocation (widget, &allocation);

  /* dragged toggles have a "soft" grab, so we don't care whether we
   * are in the switch or not when the button is released; we do care
   * for direct toggles, instead
   */
  if (!priv->is_dragging && !priv->in_switch)
    return FALSE;

  /* direct toggle */
  if (priv->in_press)
    {
      priv->in_press = FALSE;
      gtk_switch_set_active (GTK_SWITCH (widget), !priv->is_active);

      return TRUE;
    }

  /* toggle the switch if the handle was clicked but a drag had not been
   * initiated */
  if (!priv->is_dragging && !priv->in_press)
    {
      gtk_switch_set_active (GTK_SWITCH (widget), !priv->is_active);

      return TRUE;
    }

  /* dragged toggle */
  if (priv->is_dragging)
    {
      priv->is_dragging = FALSE;

      /* if half the handle passed the middle of the switch, then we
       * consider it to be on
       */
      if ((priv->handle_x + (allocation.width / 4)) >= (allocation.width / 2))
        {
          gtk_switch_set_active (GTK_SWITCH (widget), TRUE);
          priv->handle_x = allocation.width / 2;
        }
      else
        {
          gtk_switch_set_active (GTK_SWITCH (widget), FALSE);
          priv->handle_x = 0;
        }

      gtk_widget_queue_draw (widget);

      return TRUE;
    }

  return FALSE;
}
static void
extension_switch_activated_cb (GObject    *gobject,
			       GParamSpec *pspec,
			       gpointer    user_data)
{
	RowData			*row_data = user_data;
	BrowserData		*browser_data = row_data->browser_data;
	GthExtensionDescription *description = row_data->description;
	GError                  *error = NULL;

	if (! gth_extension_description_is_active (description)) {
		if (! gth_extension_manager_activate (gth_main_get_default_extension_manager (), description->id, &error)) {
			_gtk_error_dialog_from_gerror_run (GTK_WINDOW (browser_data->dialog), _("Could not activate the extension"), error);
			g_clear_error (&error);

			g_signal_handlers_block_by_data (gobject, user_data);
			gtk_switch_set_active (GTK_SWITCH (gobject), FALSE);
			g_signal_handlers_unblock_by_data (gobject, user_data);
		}
		else
			browser_data->enabled_disabled_cardinality_changed = TRUE;
	}
	else {
		if (! gth_extension_manager_deactivate (gth_main_get_default_extension_manager (), description->id, &error)) {
			_gtk_error_dialog_from_gerror_run (GTK_WINDOW (browser_data->dialog), _("Could not deactivate the extension"), error);
			g_clear_error (&error);

			g_signal_handlers_block_by_data (gobject, user_data);
			gtk_switch_set_active (GTK_SWITCH (gobject), TRUE);
			g_signal_handlers_unblock_by_data (gobject, user_data);
		}
		else
			browser_data->enabled_disabled_cardinality_changed = TRUE;
	}
}
static void
gis_privacy_page_constructed (GObject *object)
{
  GisPrivacyPage *page = GIS_PRIVACY_PAGE (object);
  GisPrivacyPagePrivate *priv = gis_privacy_page_get_instance_private (page);

  G_OBJECT_CLASS (gis_privacy_page_parent_class)->constructed (object);

  gis_page_set_complete (GIS_PAGE (page), TRUE);

  priv->location_settings = g_settings_new ("org.gnome.system.location");
  priv->privacy_settings = g_settings_new ("org.gnome.desktop.privacy");

  gtk_switch_set_active (GTK_SWITCH (priv->location_switch), TRUE);
  gtk_switch_set_active (GTK_SWITCH (priv->reporting_switch), TRUE);

  update_os_data (page);

  priv->abrt_watch_id = g_bus_watch_name (G_BUS_TYPE_SYSTEM,
                                          "org.freedesktop.problems.daemon",
                                          G_BUS_NAME_WATCHER_FLAGS_NONE,
                                          abrt_appeared_cb,
                                          abrt_vanished_cb,
                                          page,
                                          NULL);
}
static void
g_paste_settings_ui_stack_settings_changed (GPasteSettings *settings,
                                            const gchar    *key,
                                            gpointer        user_data)
{
    GPasteSettingsUiStackPrivate *priv = user_data;

    if (!g_strcmp0 (key, G_PASTE_ELEMENT_SIZE_SETTING))
        gtk_spin_button_set_value (priv->element_size_button, g_paste_settings_get_element_size (settings));
    else if (!g_strcmp0 (key, G_PASTE_GROWING_LINES_SETTING))
        gtk_switch_set_active (GTK_SWITCH (priv->growing_lines_switch), g_paste_settings_get_growing_lines (settings));
    else if (!g_strcmp0 (key, G_PASTE_HISTORY_NAME_SETTING))
    {
        G_PASTE_CLEANUP_FREE gchar *text = g_strconcat (g_paste_settings_get_history_name (settings), "_backup", NULL);
        gtk_entry_set_text (priv->backup_entry, text);
        g_paste_settings_ui_stack_private_refill_histories (priv);
    }
    else if (!g_strcmp0 (key, G_PASTE_IMAGES_SUPPORT_SETTING))
        gtk_switch_set_active (GTK_SWITCH (priv->images_support_switch), g_paste_settings_get_images_support (settings));
    else if (!g_strcmp0 (key, G_PASTE_MAKE_PASSWORD_SETTING))
        gtk_entry_set_text (priv->make_password_entry, g_paste_settings_get_make_password (settings));
    else if (!g_strcmp0 (key, G_PASTE_MAX_DISPLAYED_HISTORY_SIZE_SETTING))
        gtk_spin_button_set_value (priv->max_displayed_history_size_button, g_paste_settings_get_max_displayed_history_size (settings));
    else if (!g_strcmp0 (key, G_PASTE_MAX_HISTORY_SIZE_SETTING))
        gtk_spin_button_set_value (priv->max_history_size_button, g_paste_settings_get_max_history_size (settings));
    else if (!g_strcmp0 (key, G_PASTE_MAX_MEMORY_USAGE_SETTING))
        gtk_spin_button_set_value (priv->max_memory_usage_button, g_paste_settings_get_max_memory_usage (settings));
    else if (!g_strcmp0 (key, G_PASTE_MAX_TEXT_ITEM_SIZE_SETTING))
        gtk_spin_button_set_value (priv->max_text_item_size_button, g_paste_settings_get_max_text_item_size (settings));
    else if (!g_strcmp0 (key, G_PASTE_MIN_TEXT_ITEM_SIZE_SETTING))
        gtk_spin_button_set_value (priv->min_text_item_size_button, g_paste_settings_get_min_text_item_size (settings));
    else if (!g_strcmp0 (key, G_PASTE_POP_SETTING))
        gtk_entry_set_text (priv->pop_entry, g_paste_settings_get_pop (settings));
    else if (!g_strcmp0 (key, G_PASTE_PRIMARY_TO_HISTORY_SETTING ))
        gtk_switch_set_active (GTK_SWITCH (priv->primary_to_history_switch), g_paste_settings_get_primary_to_history (settings));
    else if (!g_strcmp0 (key, G_PASTE_SAVE_HISTORY_SETTING))
        gtk_switch_set_active (GTK_SWITCH (priv->save_history_switch), g_paste_settings_get_save_history (settings));
    else if (!g_strcmp0 (key, G_PASTE_SHOW_HISTORY_SETTING))
        gtk_entry_set_text (priv->show_history_entry, g_paste_settings_get_show_history (settings));
    else if (!g_strcmp0 (key, G_PASTE_SYNC_CLIPBOARD_TO_PRIMARY_SETTING))
        gtk_entry_set_text (priv->sync_clipboard_to_primary_entry, g_paste_settings_get_sync_clipboard_to_primary (settings));
    else if (!g_strcmp0 (key, G_PASTE_SYNC_PRIMARY_TO_CLIPBOARD_SETTING))
        gtk_entry_set_text (priv->sync_primary_to_clipboard_entry, g_paste_settings_get_sync_primary_to_clipboard (settings));
    else if (!g_strcmp0 (key, G_PASTE_SYNCHRONIZE_CLIPBOARDS_SETTING))
        gtk_switch_set_active (GTK_SWITCH (priv->synchronize_clipboards_switch), g_paste_settings_get_synchronize_clipboards (settings));
    else if (!g_strcmp0 (key, G_PASTE_TRACK_CHANGES_SETTING))
        gtk_switch_set_active (GTK_SWITCH (priv->track_changes_switch), g_paste_settings_get_track_changes (settings));
    else if (!g_strcmp0 (key, G_PASTE_TRIM_ITEMS_SETTING))
        gtk_switch_set_active (GTK_SWITCH (priv->trim_items_switch), g_paste_settings_get_trim_items (settings));
#if G_PASTE_CONFIG_ENABLE_EXTENSION
    else if (!g_strcmp0 (key, G_PASTE_EXTENSION_ENABLED_SETTING))
        gtk_switch_set_active (GTK_SWITCH (priv->extension_enabled_switch), g_paste_settings_get_extension_enabled (settings));
    else if (!g_strcmp0 (key, G_PASTE_TRACK_EXTENSION_STATE_SETTING))
        gtk_switch_set_active (GTK_SWITCH (priv->track_extension_state_switch), g_paste_settings_get_track_extension_state (settings));
#endif
}
Exemple #5
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, 0);
  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, 0);
  gtk_widget_show (label);

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

  return hbox;
}
Exemple #6
0
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);
    }
}
Exemple #7
0
JNIEXPORT void JNICALL
Java_org_gnome_gtk_GtkSwitch_gtk_1switch_1set_1active
(
	JNIEnv* env,
	jclass cls,
	jlong _self,
	jboolean _isActive
)
{
	GtkSwitch* self;
	gboolean isActive;

	// convert parameter self
	self = (GtkSwitch*) _self;

	// convert parameter isActive
	isActive = (gboolean) _isActive;

	// call function
	gtk_switch_set_active(self, isActive);

	// cleanup parameter self

	// cleanup parameter isActive
}
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;
}
Exemple #9
0
static void
ide_editor_spell__widget_mapped_cb (IdeEditorSpellWidget *self)
{
  GActionGroup *group = NULL;
  GtkWidget *widget = GTK_WIDGET (self->view);
  g_autoptr (GVariant) value = NULL;

  g_assert (IDE_IS_EDITOR_SPELL_WIDGET (self));

  while ((group == NULL) && (widget != NULL))
    {
      group = gtk_widget_get_action_group (widget, "view");
      widget = gtk_widget_get_parent (widget);
    }

  if (group != NULL &&
      NULL != (self->view_spellchecking_action = g_action_map_lookup_action (G_ACTION_MAP (group),
                                                                             "spellchecking")))
    {
      value = g_action_get_state (self->view_spellchecking_action);
      self->view_spellchecker_set = g_variant_get_boolean (value);
      gtk_switch_set_active (GTK_SWITCH (self->highlight_switch), self->view_spellchecker_set);
    }

  jump_to_next_misspelled_word (self);
}
Exemple #10
0
static void
gtk_switch_begin_toggle_animation (GtkSwitch *sw)
{
  GtkSwitchPrivate *priv = sw->priv;
  gboolean animate;

  g_object_get (gtk_widget_get_settings (GTK_WIDGET (sw)),
                "gtk-enable-animations", &animate,
                NULL);

  if (animate)
    {
      GdkFrameClock *clock = gtk_widget_get_frame_clock (GTK_WIDGET (sw));
      priv->start_time = gdk_frame_clock_get_frame_time (clock);
      priv->end_time = priv->start_time + 1000 * ANIMATION_DURATION;
      priv->offset = priv->handle_x;
      if (priv->tick_id == 0)
        {
          priv->tick_id = g_signal_connect (clock, "update",
                                            G_CALLBACK (gtk_switch_on_frame_clock_update), sw);
          gdk_frame_clock_begin_updating (clock);
        }
    }
  else
    {
      gtk_switch_set_active (sw, !priv->is_active);
    }
}
Exemple #11
0
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_STATE:
      gtk_switch_set_state (sw, g_value_get_boolean (value));
      break;

    case PROP_ACTION_NAME:
      gtk_switch_set_action_name (GTK_ACTIONABLE (sw), g_value_get_string (value));
      break;

    case PROP_ACTION_TARGET:
      gtk_switch_set_action_target_value (GTK_ACTIONABLE (sw), g_value_get_variant (value));
      break;

    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
    }
}
Exemple #12
0
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;
}
static void technology_property_changed_cb(const char *path,
					const char *property, void *user_data)
{
	GtkTechnology *technology = user_data;
	GtkTechnologyPrivate *priv = technology->priv;

	if (g_strcmp0(property, "Powered") == 0) {
		gboolean enabled;

		enabled = connman_technology_is_enabled(path);

		gtk_switch_set_active(priv->enabler, enabled);
		gtk_widget_set_sensitive((GtkWidget *)priv->enabler, TRUE);

		gtk_widget_set_sensitive((GtkWidget *)priv->tethering,
								enabled);

		set_technology_name(technology, enabled);
	} else if (g_strcmp0(property, "Tethering") == 0) {
		gtk_check_menu_item_set_active(priv->tethering,
					connman_technology_is_tethering(path));
		gtk_widget_set_sensitive((GtkWidget *)priv->tethering,
					connman_technology_is_enabled(path));
	}
}
Exemple #14
0
static void
gtk_switch_update (GtkActivatable *activatable,
                   GtkAction      *action,
                   const gchar    *property_name)
{
  G_GNUC_BEGIN_IGNORE_DEPRECATIONS;

  if (strcmp (property_name, "visible") == 0)
    {
      if (gtk_action_is_visible (action))
        gtk_widget_show (GTK_WIDGET (activatable));
      else
        gtk_widget_hide (GTK_WIDGET (activatable));
    }
  else if (strcmp (property_name, "sensitive") == 0)
    {
      gtk_widget_set_sensitive (GTK_WIDGET (activatable), gtk_action_is_sensitive (action));
    }
  else if (strcmp (property_name, "active") == 0)
    {
      gtk_action_block_activate (action);
      gtk_switch_set_active (GTK_SWITCH (activatable), gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)));
      gtk_action_unblock_activate (action);
    }

  G_GNUC_END_IGNORE_DEPRECATIONS;
}
Exemple #15
0
/**
 * gtk_switch_set_state:
 * @sw: a #GtkSwitch
 * @state: the new state
 *
 * Sets the underlying state of the #GtkSwitch.
 *
 * Normally, this is the same as #GtkSwitch:active, unless the switch
 * is set up for delayed state changes. This function is typically
 * called from a #GtkSwitch::state-set signal handler.
 *
 * See #GtkSwitch::state-set for details.
 *
 * Since: 3.14
 */
void
gtk_switch_set_state (GtkSwitch *sw,
                      gboolean   state)
{
  g_return_if_fail (GTK_IS_SWITCH (sw));

  state = state != FALSE;

  if (sw->priv->state == state)
    return;

  sw->priv->state = state;

  /* This will be a no-op if we're switching the state in response
   * to a UI change. We're setting active anyway, to catch 'spontaneous'
   * state changes.
   */
  gtk_switch_set_active (sw, state);

  if (state)
    gtk_widget_set_state_flags (GTK_WIDGET (sw), GTK_STATE_FLAG_CHECKED, FALSE);
  else
    gtk_widget_unset_state_flags (GTK_WIDGET (sw), GTK_STATE_FLAG_CHECKED);

  g_object_notify (G_OBJECT (sw), "state");
}
Exemple #16
0
static void
gtk_switch_on_frame_clock_update (GdkFrameClock *clock,
                                  GtkSwitch     *sw)
{
  GtkSwitchPrivate *priv = sw->priv;
  gint64 now;

  now = gdk_frame_clock_get_frame_time (clock);

  if (now < priv->end_time)
    {
      gdouble t;
      gint dest_offset;

      if (priv->is_active)
        dest_offset = 0;
      else
        dest_offset = gtk_widget_get_allocated_width (GTK_WIDGET (sw)) / 2;

      t = (now - priv->start_time) / (gdouble) (priv->end_time - priv->start_time);
      t = ease_out_cubic (t);
      priv->handle_x = priv->offset + t * (dest_offset - priv->offset);
    }
  else
    {
      gtk_switch_set_active (sw, !priv->is_active);
    }

  gtk_widget_queue_draw (GTK_WIDGET (sw));
}
Exemple #17
0
int main (int argc, char *argv[])
{
  GtkWidget *window;
  GtkWidget *box;
  GtkWidget *bu;
  GtkWidget *w, *c;

  gtk_init (&argc, &argv);

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
  gtk_container_add (GTK_CONTAINER (window), box);

  w = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 15);
  gtk_box_pack_start (GTK_BOX (box), w, TRUE, TRUE, 0);
  gtk_box_pack_start (GTK_BOX (w), gtk_entry_new (), TRUE, TRUE, 0);
  bu = gtk_button_new_with_label ("Bu");
  gtk_box_pack_start (GTK_BOX (w), bu, TRUE, TRUE, 0);
  c = gtk_switch_new ();
  gtk_switch_set_active (GTK_SWITCH (c), TRUE);
  gtk_widget_set_halign (c, GTK_ALIGN_CENTER);
  gtk_widget_set_valign (c, GTK_ALIGN_CENTER);
  gtk_box_pack_start (GTK_BOX (box), c, TRUE, TRUE, 0);
  g_signal_connect (bu, "clicked", G_CALLBACK (set_insensitive), w);
  g_signal_connect (bu, "state-changed", G_CALLBACK (state_changed), NULL);

  g_object_bind_property (c, "active", w, "sensitive", G_BINDING_BIDIRECTIONAL);

  gtk_widget_show_all (window);

  gtk_main ();

  return 0;
}
Exemple #18
0
static gboolean
gtk_switch_on_frame_clock_update (GtkWidget     *widget,
                                  GdkFrameClock *clock,
                                  gpointer       user_data)
{
  GtkSwitch *sw = GTK_SWITCH (widget);
  GtkSwitchPrivate *priv = sw->priv;

  gtk_progress_tracker_advance_frame (&priv->tracker,
                                      gdk_frame_clock_get_frame_time (clock));

  if (gtk_progress_tracker_get_state (&priv->tracker) != GTK_PROGRESS_STATE_AFTER)
    {
      if (priv->is_active)
        priv->handle_pos = 1.0 - gtk_progress_tracker_get_ease_out_cubic (&priv->tracker, FALSE);
      else
        priv->handle_pos = gtk_progress_tracker_get_ease_out_cubic (&priv->tracker, FALSE);
    }
  else
    {
      gtk_switch_set_active (sw, !priv->is_active);
    }

  gtk_widget_queue_allocate (GTK_WIDGET (sw));

  return G_SOURCE_CONTINUE;
}
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;
}
Exemple #20
0
static void
gtk_switch_pan_gesture_drag_end (GtkGestureDrag *gesture,
                                 gdouble         x,
                                 gdouble         y,
                                 GtkSwitch      *sw)
{
  GtkSwitchPrivate *priv = sw->priv;
  GdkEventSequence *sequence;
  GtkAllocation allocation;
  gboolean active;

  sequence = gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (gesture));

  if (gtk_gesture_get_sequence_state (GTK_GESTURE (gesture), sequence) == GTK_EVENT_SEQUENCE_CLAIMED)
    {
      gtk_widget_get_allocation (GTK_WIDGET (sw), &allocation);

      /* if half the handle passed the middle of the switch, then we
       * consider it to be on
       */
      active = priv->handle_pos >= 0.5;
    }
  else if (!gtk_gesture_handles_sequence (priv->multipress_gesture, sequence))
    active = priv->is_active;
  else
    return;

  priv->handle_pos = active ? 1.0 : 0.0;
  gtk_switch_set_active (sw, active);
  gtk_widget_queue_allocate (GTK_WIDGET (sw));
}
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);
}
Exemple #22
0
static void
gtk_switch_activate (GtkSwitch *sw)
{
  GtkSwitchPrivate *priv = sw->priv;

  gtk_switch_set_active (sw, !priv->is_active);
}
static void
toggle_switch (GtkWidget *sw)
{
  gboolean active;

  active = gtk_switch_get_active (GTK_SWITCH (sw));
  gtk_switch_set_active (GTK_SWITCH (sw), !active);
}
static void
cc_wacom_mapping_panel_init (CcWacomMappingPanel *self)
{
	CcWacomMappingPanelPrivate *priv;
	GtkWidget *vbox, *grid;
	GtkCellRenderer *renderer;

	priv = self->priv = WACOM_MAPPING_PANEL_PRIVATE (self);

	vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 8);
	gtk_container_add (GTK_CONTAINER (self), vbox);
	gtk_container_set_border_width (GTK_CONTAINER (self), 12);
	gtk_widget_set_vexpand (GTK_WIDGET (vbox), TRUE);
	gtk_widget_set_hexpand (GTK_WIDGET (vbox), TRUE);

	/* Output Combobox */
	grid = gtk_grid_new();
	gtk_grid_set_row_spacing (GTK_GRID (grid), 10);
	gtk_grid_set_column_spacing (GTK_GRID (grid), 10);
	priv->label = gtk_label_new (_("Output:"));
	gtk_widget_set_halign (priv->label, GTK_ALIGN_END);
	priv->combobox = gtk_combo_box_new ();
	g_signal_connect (G_OBJECT (priv->combobox), "changed",
	                      G_CALLBACK (combobox_changed_cb), self);
	renderer = gtk_cell_renderer_text_new ();
	gtk_cell_layout_pack_start (GTK_CELL_LAYOUT(priv->combobox), renderer, TRUE);
	gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT(priv->combobox), renderer, "text", 0);
	gtk_grid_attach (GTK_GRID(grid), GTK_WIDGET(priv->label), 0, 0, 1, 1);
	gtk_grid_attach (GTK_GRID(grid), GTK_WIDGET(priv->combobox), 1, 0, 1, 1);

	/* Keep ratio switch */
	priv->aspectlabel = gtk_label_new (_("Keep aspect ratio (letterbox):"));
	gtk_widget_set_halign (priv->aspectlabel, GTK_ALIGN_END);
	priv->aspectswitch = gtk_switch_new ();
	gtk_widget_set_halign (priv->aspectswitch, GTK_ALIGN_START);
	gtk_switch_set_active (GTK_SWITCH (priv->aspectswitch), FALSE);
	g_signal_connect (GTK_SWITCH (priv->aspectswitch), "notify::active",
                      G_CALLBACK (aspectswitch_toggled_cb), self);
	gtk_grid_attach (GTK_GRID(grid), GTK_WIDGET(priv->aspectlabel), 0, 1, 1, 1);
	gtk_grid_attach (GTK_GRID(grid), GTK_WIDGET(priv->aspectswitch), 1, 1, 1, 1);

	/* Whole-desktop checkbox */
	priv->checkbutton = gtk_check_button_new_with_label (_("Map to single monitor"));
	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->checkbutton), FALSE);
	g_signal_connect (G_OBJECT (priv->checkbutton), "toggled",
                      G_CALLBACK (checkbutton_toggled_cb), self);

	gtk_box_pack_start (GTK_BOX(vbox), GTK_WIDGET(priv->checkbutton),
				FALSE, FALSE, 0);
	gtk_box_pack_start (GTK_BOX(vbox), GTK_WIDGET(grid),
				FALSE, FALSE, 8);

	/* Update display */
	cc_wacom_mapping_panel_set_device (self, NULL);
	gtk_widget_show_all(GTK_WIDGET(self));
}
Exemple #25
0
void open_uoptions(char *path, struct program_options *orig) {
    char    items[2048];
    int     count;

    load_uoptions_from_file(path, 1);
    if (orig != NULL) {
        oldest = orig;
        memcpy(&newest, oldest, sizeof(newest));
        if (oldest->poll_period > 0) {
            gtk_switch_set_active(uoptions_Poll_Switch, 1);
            gtk_spin_button_set_value(uoptions_Poll_Input, oldest->poll_period);
        }
        if (oldest->mouse_period > 0) {
            gtk_switch_set_active(uoptions_Jiggle_Switch, 1);
            gtk_spin_button_set_value(uoptions_Jiggle_Input, oldest->mouse_period);
        }
        if (oldest->mouse_dist > 0) {
            gtk_switch_set_active(uoptions_Distance_Switch, 1);
            gtk_spin_button_set_value(uoptions_Distance_Input, oldest->mouse_dist);
        }
        if (oldest->idle_threshold > 0) {
            gtk_switch_set_active(uoptions_Idle_Switch, 1);
            gtk_spin_button_set_value(uoptions_Idle_Input, oldest->idle_threshold);
        }
        if (strcmp(oldest->time_format, "")) {
            gtk_switch_set_active(uoptions_TFmt_Switch, 1);
            gtk_entry_set_text(uoptions_TFmt_Input, oldest->time_format);
        }
        if (strcmp(oldest->filename, "")) {
            gtk_switch_set_active(uoptions_File_Switch, 1);
            gtk_entry_set_text(uoptions_File_Input, oldest->filename);
        }
        if (oldest->use_database) {
            gtk_switch_set_active(uoptions_Db_Switch, 1);
        }
        if (strcmp(oldest->dbname, "")) {
            gtk_entry_set_text(uoptions_Db_Input, oldest->dbname);
        }
        if (oldest->menu_len > 0) {
            items[0] = '\000';
            for (count = 0; count < oldest->menu_len; count++) {
                strcat(items, oldest->menu_items[count]);
                if (count + 1 < oldest->menu_len) {
                    strcat(items, ",");
                }
            }
            gtk_entry_set_text(uoptions_UserDef_Input, items);
            gtk_switch_set_active(uoptions_UserDef_Switch, 1);
        }
    }
    gtk_widget_show_all((GtkWidget*)GTK_WINDOW(uoptions_uManage_Options));
}
Exemple #26
0
/* 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
}
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);
}
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;
	}
}
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);
}
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);
}