static void
impl_activate (PeasActivatable *activatable)
{
	RBVisualizerPlugin *pi = RB_VISUALIZER_PLUGIN (activatable);
	RBDisplayPageGroup *page_group;
	RhythmDBEntry *entry;
	GSimpleAction *fullscreen;
	RBShell *shell;
	GMenu *menu;

	g_object_get (pi, "object", &shell, NULL);

	pi->settings = g_settings_new ("org.gnome.rhythmbox.plugins.visualizer");
	g_signal_connect_object (pi->settings, "changed", G_CALLBACK (settings_changed_cb), pi, 0);

	/* create UI actions and menus and stuff */
	fullscreen = g_simple_action_new_stateful ("visualizer-toggle", G_VARIANT_TYPE_BOOLEAN, g_variant_new_boolean (FALSE));
	menu = rb_visualizer_create_popup_menu ("app.visualizer-toggle");
	g_object_ref_sink (menu);

	/* create visualizer page */
	pi->page = rb_visualizer_page_new (G_OBJECT (pi), shell, fullscreen, G_MENU_MODEL (menu));
	g_signal_connect_object (pi->page, "start", G_CALLBACK (start_visualizer_cb), pi, 0);
	g_signal_connect_object (pi->page, "stop", G_CALLBACK (stop_visualizer_cb), pi, 0);

	/* don't do anything if we couldn't create a video sink (clutter is broken, etc.) */
	g_object_get (pi->page, "sink", &pi->sink, NULL);
	if (pi->sink == NULL) {
		g_object_unref (shell);
		return;
	}

	/* prepare style stuff for fullscreen display */
	rb_visualizer_fullscreen_load_style (G_OBJECT (pi));

	/* add the visualizer page to the UI */
	page_group = rb_display_page_group_get_by_id ("display");
	if (page_group == NULL) {
		page_group = rb_display_page_group_new (G_OBJECT (shell),
							"display",
							_("Display"),
							RB_DISPLAY_PAGE_GROUP_CATEGORY_TOOLS);
		rb_shell_append_display_page (shell, RB_DISPLAY_PAGE (page_group), NULL);
	}
	g_object_set (pi->page, "visibility", FALSE, NULL);

	rb_shell_append_display_page (shell, RB_DISPLAY_PAGE (pi->page), RB_DISPLAY_PAGE (page_group));

	/* get player objects */
	g_object_get (shell, "shell-player", &pi->shell_player, NULL);
	g_object_get (pi->shell_player, "player", &pi->player, NULL);

	/* only show the page in the page tree when playing something */
	g_signal_connect_object (pi->shell_player, "playing-song-changed", G_CALLBACK (playing_song_changed_cb), pi, 0);
	entry = rb_shell_player_get_playing_entry (pi->shell_player);
	playing_song_changed_cb (pi->shell_player, entry, pi);
	if (entry != NULL) {
		rhythmdb_entry_unref (entry);
	}

	/* figure out how to insert the visualizer into the playback pipeline */
	if (g_object_class_find_property (G_OBJECT_GET_CLASS (pi->player), "playbin")) {

		rb_debug ("using playbin-based visualization");
		pi->playbin_notify_id = g_signal_connect_object (pi->player,
								 "notify::playbin",
								 G_CALLBACK (playbin_notify_cb),
								 pi,
								 0);
		g_object_get (pi->player, "playbin", &pi->playbin, NULL);
		if (pi->playbin != NULL) {
			mutate_playbin (pi, pi->playbin);
		}
	} else if (RB_IS_PLAYER_GST_TEE (pi->player)) {
		rb_debug ("using tee-based visualization");
	} else {
		g_warning ("unknown player backend type");
		g_object_unref (pi->player);
		pi->player = NULL;
	}

	g_object_unref (shell);
}
static void
cc_screen_panel_init (CcScreenPanel *self)
{
    GError     *error;
    GtkWidget  *widget;

    self->priv = SCREEN_PANEL_PRIVATE (self);

    self->priv->builder = gtk_builder_new ();

    error = NULL;
    gtk_builder_add_from_file (self->priv->builder,
                               GNOMECC_UI_DIR "/screen.ui",
                               &error);

    if (error != NULL)
    {
        g_warning ("Could not load interface file: %s", error->message);
        g_error_free (error);
        return;
    }

    self->priv->cancellable = g_cancellable_new ();

    /* get initial brightness version */
    g_dbus_proxy_new_for_bus (G_BUS_TYPE_SESSION,
                              G_DBUS_PROXY_FLAGS_NONE,
                              NULL,
                              "org.gnome.SettingsDaemon",
                              "/org/gnome/SettingsDaemon/Power",
                              "org.gnome.SettingsDaemon.Power.Screen",
                              self->priv->cancellable,
                              got_power_proxy_cb,
                              self);

    self->priv->lock_settings = g_settings_new ("org.gnome.desktop.screensaver");
    g_signal_connect (self->priv->lock_settings,
                      "changed",
                      G_CALLBACK (on_lock_settings_changed),
                      self);
    self->priv->gsd_settings = g_settings_new ("org.gnome.settings-daemon.plugins.power");
    self->priv->session_settings = g_settings_new ("org.gnome.desktop.session");
    self->priv->lockdown_settings = g_settings_new ("org.gnome.desktop.lockdown");
    g_signal_connect (self->priv->lockdown_settings,
                      "changed",
                      G_CALLBACK (on_lockdown_settings_changed),
                      self);

    /* bind the auto dim checkbox */
    widget = WID ("screen_auto_reduce_checkbutton");
    g_settings_bind (self->priv->gsd_settings,
                     "idle-dim-battery",
                     widget, "active",
                     G_SETTINGS_BIND_DEFAULT);

    /* display off time */
    widget = WID ("screen_brightness_combobox");
    set_dpms_value_for_combo (GTK_COMBO_BOX (widget), self);
    g_signal_connect (widget, "changed",
                      G_CALLBACK (dpms_combo_changed_cb),
                      self);

    /* bind the screen lock checkbox */
    widget = WID ("screen_lock_on_switch");
    g_settings_bind (self->priv->lock_settings,
                     "lock-enabled",
                     widget, "active",
                     G_SETTINGS_BIND_DEFAULT);

    /* lock time */
    widget = WID ("screen_lock_combobox");
    set_lock_value_for_combo (GTK_COMBO_BOX (widget), self);
    g_signal_connect (widget, "changed",
                      G_CALLBACK (lock_combo_changed_cb),
                      self);

    widget = WID ("screen_lock_hbox");
    g_settings_bind (self->priv->lock_settings,
                     "lock-enabled",
                     widget, "sensitive",
                     G_SETTINGS_BIND_GET);

    widget = WID ("show_notifications_check");
    g_settings_bind (self->priv->lock_settings,
                     "show-notifications",
                     widget, "active",
                     G_SETTINGS_BIND_DEFAULT);
    if (!g_strcmp0(g_getenv("XDG_CURRENT_DESKTOP"), "Unity"))
        gtk_widget_hide (widget);

    update_lock_screen_sensitivity (self);

    /* bind the screen lock suspend checkbutton */
    widget = WID ("screen_lock_suspend_checkbutton");
    g_settings_bind (self->priv->lock_settings,
                     "ubuntu-lock-on-suspend",
                     widget, "active",
                     G_SETTINGS_BIND_DEFAULT);

    widget = WID ("screen_vbox");
    gtk_widget_reparent (widget, (GtkWidget *) self);
    g_object_set (self, "valign", GTK_ALIGN_START, NULL);
}
Example #3
0
void
modeline_parser_apply_modeline (GtkSourceView *view)
{
	ModelineOptions options;
	GtkTextBuffer *buffer;
	GtkTextIter iter, liter;
	gint line_count;
	GSettings *settings;

	options.language_id = NULL;
	options.set = MODELINE_SET_NONE;

	buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
	gtk_text_buffer_get_start_iter (buffer, &iter);

	line_count = gtk_text_buffer_get_line_count (buffer);

	/* Parse the modelines on the 10 first lines... */
	while ((gtk_text_iter_get_line (&iter) < 10) &&
	       !gtk_text_iter_is_end (&iter))
	{
		gchar *line;

		liter = iter;
		gtk_text_iter_forward_to_line_end (&iter);
		line = gtk_text_buffer_get_text (buffer, &liter, &iter, TRUE);

		parse_modeline (line,
				1 + gtk_text_iter_get_line (&iter),
				line_count,
				&options);

		gtk_text_iter_forward_line (&iter);

		g_free (line);
	}

	/* ...and on the 10 last ones (modelines are not allowed in between) */
	if (!gtk_text_iter_is_end (&iter))
	{
		gint cur_line;
		guint remaining_lines;

		/* we are on the 11th line (count from 0) */
		cur_line = gtk_text_iter_get_line (&iter);
		/* g_assert (10 == cur_line); */

		remaining_lines = line_count - cur_line - 1;

		if (remaining_lines > 10)
		{
			gtk_text_buffer_get_end_iter (buffer, &iter);
			gtk_text_iter_backward_lines (&iter, 9);
		}
	}

	while (!gtk_text_iter_is_end (&iter))
	{
		gchar *line;

		liter = iter;
		gtk_text_iter_forward_to_line_end (&iter);
		line = gtk_text_buffer_get_text (buffer, &liter, &iter, TRUE);

		parse_modeline (line,
				1 + gtk_text_iter_get_line (&iter),
				line_count,
				&options);

		gtk_text_iter_forward_line (&iter);

		g_free (line);
	}

	/* Try to set language */
	if (has_option (&options, MODELINE_SET_LANGUAGE) && options.language_id)
	{
		if (g_ascii_strcasecmp (options.language_id, "text") == 0)
		{
			gedit_document_set_language (GEDIT_DOCUMENT (buffer),
			                             NULL);
		}
		else
		{
		        GtkSourceLanguageManager *manager;
		        GtkSourceLanguage *language;

		        manager = gtk_source_language_manager_get_default ();

			language = gtk_source_language_manager_get_language
					(manager, options.language_id);
			if (language != NULL)
			{
				gedit_document_set_language (GEDIT_DOCUMENT (buffer),
				                             language);
			}
			else
			{
				gedit_debug_message (DEBUG_PLUGINS,
						     "Unknown language `%s'",
						     options.language_id);
			}
		}
	}

	ModelineOptions *previous = g_object_get_data (G_OBJECT (buffer), 
	                                               MODELINE_OPTIONS_DATA_KEY);

	settings = g_settings_new ("org.gnome.gedit.preferences.editor");

	/* Apply the options we got from modelines and restore defaults if
	   we set them before */
	if (has_option (&options, MODELINE_SET_INSERT_SPACES))
	{
		gtk_source_view_set_insert_spaces_instead_of_tabs
							(view, options.insert_spaces);
	}
	else if (check_previous (view, previous, MODELINE_SET_INSERT_SPACES))
	{
		gboolean insert_spaces;
		
		insert_spaces = g_settings_get_boolean (settings, GEDIT_SETTINGS_INSERT_SPACES);
	
		gtk_source_view_set_insert_spaces_instead_of_tabs (view, insert_spaces);
	}
	
	if (has_option (&options, MODELINE_SET_TAB_WIDTH))
	{
		gtk_source_view_set_tab_width (view, options.tab_width);
	}
	else if (check_previous (view, previous, MODELINE_SET_TAB_WIDTH))
	{
		guint tab_width;
		
		g_settings_get (settings, GEDIT_SETTINGS_TABS_SIZE, "u", &tab_width);
	
		gtk_source_view_set_tab_width (view, tab_width);
	}
	
	if (has_option (&options, MODELINE_SET_INDENT_WIDTH))
	{
		gtk_source_view_set_indent_width (view, options.indent_width);
	}
	else if (check_previous (view, previous, MODELINE_SET_INDENT_WIDTH))
	{
		gtk_source_view_set_indent_width (view, -1);
	}
	
	if (has_option (&options, MODELINE_SET_WRAP_MODE))
	{
		gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (view), options.wrap_mode);
	}
	else if (check_previous (view, previous, MODELINE_SET_WRAP_MODE))
	{
		GtkWrapMode mode;
		
		mode = g_settings_get_enum (settings,
					    GEDIT_SETTINGS_WRAP_MODE);
		gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (view), mode);
	}
	
	if (has_option (&options, MODELINE_SET_RIGHT_MARGIN_POSITION))
	{
		gtk_source_view_set_right_margin_position (view, options.right_margin_position);
	}
	else if (check_previous (view, previous, MODELINE_SET_RIGHT_MARGIN_POSITION))
	{
		guint right_margin_pos;
		
		g_settings_get (settings, GEDIT_SETTINGS_RIGHT_MARGIN_POSITION, "u",
				&right_margin_pos);
		gtk_source_view_set_right_margin_position (view, 
		                                           right_margin_pos);
	}
	
	if (has_option (&options, MODELINE_SET_SHOW_RIGHT_MARGIN))
	{
		gtk_source_view_set_show_right_margin (view, options.display_right_margin);
	}
	else if (check_previous (view, previous, MODELINE_SET_SHOW_RIGHT_MARGIN))
	{
		gboolean display_right_margin;
		
		display_right_margin = g_settings_get_boolean (settings,
							       GEDIT_SETTINGS_DISPLAY_RIGHT_MARGIN);
		gtk_source_view_set_show_right_margin (view, display_right_margin);
	}
	
	if (previous)
	{
		g_free (previous->language_id);
		*previous = options;
		previous->language_id = g_strdup (options.language_id);
	}
	else
	{
		previous = g_slice_new (ModelineOptions);
		*previous = options;
		previous->language_id = g_strdup (options.language_id);
		
		g_object_set_data_full (G_OBJECT (buffer), 
		                        MODELINE_OPTIONS_DATA_KEY, 
		                        previous,
		                        (GDestroyNotify)free_modeline_options);
	}

	g_object_unref (settings);
	g_free (options.language_id);
}
static void
cc_date_time_panel_init (CcDateTimePanel *self)
{
  CcDateTimePanelPrivate *priv;
  gchar *objects[] = { "datetime-panel", "region-liststore", "city-liststore",
      "month-liststore", "city-modelfilter", "city-modelsort", NULL };
  char *buttons[] = { "hour_up_button", "hour_down_button", "min_up_button",
          "min_down_button", "ampm_up_button", "ampm_down_button" };
  GtkWidget *widget;
  GtkAdjustment *adjustment;
  GError *err = NULL;
  GtkTreeModelFilter *city_modelfilter;
  GtkTreeModelSort *city_modelsort;
  guint i, num_days;
  gboolean using_ntp;
  gboolean can_use_ntp;
  int ret;
  DateEndianess endianess;
  GError *error;

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

  priv->cancellable = g_cancellable_new ();
  error = NULL;
  priv->dtm = date_time_mechanism_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
                                                          G_DBUS_PROXY_FLAGS_NONE,
                                                          "org.gnome.SettingsDaemon.DateTimeMechanism",
                                                          "/",
                                                          priv->cancellable,
                                                          &error);
  if (priv->dtm == NULL) {
        g_warning ("could not get proxy for DateTimeMechanism: %s", error->message);
        g_error_free (error);
  }

  priv->builder = gtk_builder_new ();

  ret = gtk_builder_add_objects_from_file (priv->builder, DATADIR"/datetime.ui",
                                           objects, &err);

  if (ret == 0)
    {
      g_warning ("Could not load ui: %s", err ? err->message : "No reason");
      if (err)
        g_error_free (err);
      return;
    }

  /* set up network time button */
  error = NULL;
  using_ntp = can_use_ntp = FALSE;
  if (!date_time_mechanism_call_get_using_ntp_sync (priv->dtm,
                                                    &can_use_ntp,
                                                    &using_ntp,
                                                    priv->cancellable,
                                                    &error))
    {
      g_warning ("Failed to get using ntp: %s", error->message);
      g_error_free (error);
    }

  gtk_switch_set_active (GTK_SWITCH (W("network_time_switch")), using_ntp);
  update_widget_state_for_ntp (self, using_ntp);
  g_signal_connect (W("network_time_switch"), "notify::active",
                    G_CALLBACK (change_ntp), self);

  /* set up time editing widgets */
  for (i = 0; i < G_N_ELEMENTS (buttons); i++)
    {
      g_signal_connect (W(buttons[i]), "clicked",
                        G_CALLBACK (change_time), self);
    }

  /* set up date editing widgets */
  priv->date = g_date_time_new_now_local ();
  endianess = date_endian_get_default (FALSE);
  reorder_date_widget (endianess, priv);

  /* Force the direction for the time, so that the time
   * is presented correctly for RTL languages */
  gtk_widget_set_direction (W("table2"), GTK_TEXT_DIR_LTR);

  gtk_combo_box_set_active (GTK_COMBO_BOX (W ("month-combobox")),
                            g_date_time_get_month (priv->date) - 1);
  g_signal_connect (G_OBJECT (W("month-combobox")), "changed",
                    G_CALLBACK (month_year_changed), self);

  num_days = g_date_get_days_in_month (g_date_time_get_month (priv->date),
                                       g_date_time_get_year (priv->date));
  adjustment = (GtkAdjustment*) gtk_adjustment_new (g_date_time_get_day_of_month (priv->date), 1,
                                                    num_days + 1, 1, 10, 1);
  gtk_spin_button_set_adjustment (GTK_SPIN_BUTTON (W ("day-spinbutton")),
                                  adjustment);
  g_signal_connect (G_OBJECT (W("day-spinbutton")), "value-changed",
                    G_CALLBACK (day_changed), self);

  adjustment = (GtkAdjustment*) gtk_adjustment_new (g_date_time_get_year (priv->date),
                                                    G_MINDOUBLE, G_MAXDOUBLE, 1,
                                                    10, 1);
  gtk_spin_button_set_adjustment (GTK_SPIN_BUTTON (W ("year-spinbutton")),
                                  adjustment);
  g_signal_connect (G_OBJECT (W("year-spinbutton")), "value-changed",
                    G_CALLBACK (month_year_changed), self);

  /* set up timezone map */
  priv->map = widget = (GtkWidget *) cc_timezone_map_new ();
  gtk_widget_show (widget);

  gtk_container_add (GTK_CONTAINER (gtk_builder_get_object (priv->builder,
                                                            "aspectmap")),
                     widget);

  gtk_container_add (GTK_CONTAINER (self),
                     GTK_WIDGET (gtk_builder_get_object (priv->builder,
                                                         "datetime-panel")));


  /* setup the time itself */
  priv->clock_tracker = g_object_new (GNOME_TYPE_WALL_CLOCK, NULL);
  g_signal_connect (priv->clock_tracker, "notify::clock", G_CALLBACK (on_clock_changed), self);

  priv->settings = g_settings_new (CLOCK_SCHEMA);
  clock_settings_changed_cb (priv->settings, CLOCK_FORMAT_KEY, self);
  g_signal_connect (priv->settings, "changed::" CLOCK_FORMAT_KEY,
                    G_CALLBACK (clock_settings_changed_cb), self);

  g_signal_connect (W("24h_button"), "notify::active",
                    G_CALLBACK (change_clock_settings), self);

  update_time (self);

  priv->locations = (GtkTreeModel*) gtk_builder_get_object (priv->builder,
                                                            "region-liststore");

  load_regions_model (GTK_LIST_STORE (priv->locations),
                      GTK_LIST_STORE (gtk_builder_get_object (priv->builder,
                                                              "city-liststore")));

  city_modelfilter = GTK_TREE_MODEL_FILTER (gtk_builder_get_object (priv->builder, "city-modelfilter"));

  widget = (GtkWidget*) gtk_builder_get_object (priv->builder,
                                                "region_combobox");
  city_modelsort = GTK_TREE_MODEL_SORT (gtk_builder_get_object (priv->builder, "city-modelsort"));
  gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (city_modelsort), CITY_COL_CITY_TRANSLATED,
                                        GTK_SORT_ASCENDING);

  gtk_tree_model_filter_set_visible_func (city_modelfilter,
                                          (GtkTreeModelFilterVisibleFunc) city_model_filter_func,
                                          widget,
                                          NULL);

  /* After the initial setup, so we can be sure that
   * the model is filled up */
  date_time_mechanism_call_get_timezone (priv->dtm,
                                         priv->cancellable,
                                         get_timezone_cb,
                                         self);

  /* add the lock button */
  priv->permission = polkit_permission_new_sync ("org.gnome.settingsdaemon.datetimemechanism.configure", NULL, NULL, NULL);
  if (priv->permission == NULL)
    {
      g_warning ("Your system does not have the '%s' PolicyKit files installed. Please check your installation",
                 "org.gnome.settingsdaemon.datetimemechanism.configure");
      return;
    }

  g_signal_connect (priv->permission, "notify",
                    G_CALLBACK (on_permission_changed), self);
  on_permission_changed (priv->permission, NULL, self);
}
Example #5
0
static gboolean
spawn_httpd (int port, pid_t *pid_out)
{
	char *free1, *free2, *free3, *free4, *free5, *free6, *free7, *free8, *free9;
	gboolean res;
	char *argv[10];
	char *env[10];
	int i;
	gint status;
	char *pid_filename;
	char *pidfile;
	GError *error;
	gboolean got_pidfile;
	GSettings *settings;
	char *str;
	char *public_dir;

	public_dir = lookup_public_dir ();
	ensure_conf_dir ();

	i = 0;
	free1 = argv[i++] = get_httpd_program ();
	if (argv[0] == NULL) {
		fprintf (stderr, "error finding httpd server\n");
		return FALSE;
	}

	argv[i++] = "-f";
	free2 = argv[i++] = get_httpd_config (argv[0]);
	argv[i++] = "-C";
	free3 = argv[i++] = g_strdup_printf ("Listen %d", port);

	settings = g_settings_new (GNOME_USER_SHARE_SCHEMAS);
	str = g_settings_get_string (settings,
				       FILE_SHARING_REQUIRE_PASSWORD);

	if (str && strcmp (str, "never") == 0) {
		/* Do nothing */
	} else if (str && strcmp (str, "on_write") == 0){
		argv[i++] = "-D";
		argv[i++] = "RequirePasswordOnWrite";
	} else {
		/* always, or safe fallback */
		argv[i++] = "-D";
		argv[i++] = "RequirePasswordAlways";
	}
	g_free (str);
	g_object_unref (settings);

	argv[i] = NULL;

	i = 0;
	free4 = env[i++] = g_strdup_printf ("HOME=%s", g_get_home_dir());
	free5 = env[i++] = g_strdup_printf ("XDG_PUBLICSHARE_DIR=%s", public_dir);
	free6 = env[i++] = g_strdup_printf ("XDG_CONFIG_HOME=%s", g_get_user_config_dir ());
	free7 = env[i++] = g_strdup_printf ("GUS_SHARE_NAME=%s", get_share_name ());
	free8 = env[i++] = g_strdup_printf ("GUS_LOGIN_LABEL=%s", "Please log in as the user guest");
	free9 = env[i++] = g_strdup_printf ("HTTP_MODULES_PATH=%s",get_httpd_modules_path ());
	env[i++] = "LANG=C";
	env[i] = NULL;

	pid_filename = g_build_filename (g_get_user_config_dir (), "user-share", "pid", NULL);

	/* Remove pid file before spawning to avoid races with child and old pidfile */
	unlink (pid_filename);

	error = NULL;
	res = g_spawn_sync (g_get_home_dir(),
			    argv, env, 0,
			    httpd_child_setup, NULL,
			    NULL, NULL,
			    &status,
			    &error);
	g_free (free1);
	g_free (free2);
	g_free (free3);
	g_free (free4);
	g_free (free5);
	g_free (free6);
	g_free (free7);
	g_free (free8);
	g_free (free9);
	g_free (public_dir);

	if (!res) {
		fprintf (stderr, "error spawning httpd: %s\n",
			 error->message);
		g_error_free (error);
		return FALSE;
	}

	if (status != 0) {
		g_free (pid_filename);
		return FALSE;
	}

	got_pidfile = FALSE;
	error = NULL;
	for (i = 0; i < 5; i++) {
		if (error != NULL) 
			g_error_free (error); 
		error = NULL;
		if (g_file_get_contents (pid_filename, &pidfile, NULL, &error)) {
			got_pidfile = TRUE;
			*pid_out = atoi (pidfile);
			g_free (pidfile);
			break;
		}
		sleep (1);
	}

	g_free (pid_filename);

	if (!got_pidfile) {
		fprintf (stderr, "error opening httpd pidfile: %s\n", error->message);
		g_error_free (error);
		return FALSE;
	}
	return TRUE;
}
void
caja_global_preferences_init (void)
{
    static gboolean initialized = FALSE;

    if (initialized)
    {
        return;
    }

    initialized = TRUE;
    
    caja_preferences = g_settings_new("org.mate.caja.preferences");
    caja_media_preferences = g_settings_new("org.mate.media-handling");
    caja_window_state = g_settings_new("org.mate.caja.window-state");
    caja_icon_view_preferences = g_settings_new("org.mate.caja.icon-view");
    caja_compact_view_preferences = g_settings_new("org.mate.caja.compact-view");
    caja_desktop_preferences = g_settings_new("org.mate.caja.desktop");
    caja_tree_sidebar_preferences = g_settings_new("org.mate.caja.sidebar-panels.tree");
    caja_list_view_preferences = g_settings_new("org.mate.caja.list-view");
    caja_extension_preferences = g_settings_new("org.mate.caja.extensions");

    mate_background_preferences = g_settings_new("org.mate.background");
    mate_lockdown_preferences = g_settings_new("org.mate.lockdown");
}
Example #7
0
static void
gdict_applet_init (GdictApplet *applet)
{
  GdictAppletPrivate *priv;
  gchar *data_dir;

  priv = GDICT_APPLET_GET_PRIVATE (applet);
  applet->priv = priv;
      
  if (!priv->loader)
    priv->loader = gdict_source_loader_new ();

  /* add our data dir inside $HOME to the loader's search paths */
  data_dir = gdict_get_data_dir ();
  gdict_source_loader_add_search_path (priv->loader, data_dir);
  g_free (data_dir);
  
  gtk_window_set_default_icon_name ("accessories-dictionary");
  
  mate_panel_applet_set_flags (MATE_PANEL_APPLET (applet),
			  MATE_PANEL_APPLET_EXPAND_MINOR);

  priv->settings = g_settings_new (GDICT_SETTINGS_SCHEMA);
  priv->desktop_settings = g_settings_new (DESKTOP_SETTINGS_SCHEMA);

  g_signal_connect (priv->settings, "changed",
                    G_CALLBACK (gdict_applet_settings_changed_cb), applet);

  g_signal_connect (priv->desktop_settings, "changed",
                    G_CALLBACK (gdict_applet_settings_changed_cb), applet);

#ifndef GDICT_APPLET_STAND_ALONE
  mate_panel_applet_set_background_widget (MATE_PANEL_APPLET (applet),
		  		      GTK_WIDGET (applet));

  priv->size = mate_panel_applet_get_size (MATE_PANEL_APPLET (applet));

  switch (mate_panel_applet_get_orient (MATE_PANEL_APPLET (applet)))
    {
    case MATE_PANEL_APPLET_ORIENT_LEFT:
    case MATE_PANEL_APPLET_ORIENT_RIGHT:
      priv->orient = GTK_ORIENTATION_VERTICAL;
      break;
    case MATE_PANEL_APPLET_ORIENT_UP:
    case MATE_PANEL_APPLET_ORIENT_DOWN:
      priv->orient = GTK_ORIENTATION_HORIZONTAL;
      break;
    }
#else
  priv->size = 24;
  priv->orient = GTK_ORIENTATION_HORIZONTAL;
  g_message ("(in %s) applet { size = %d, orient = %s }",
  	     G_STRFUNC,
  	     priv->size,
  	     (priv->orient == GTK_ORIENTATION_HORIZONTAL ? "H" : "V"));
#endif /* !GDICT_APPLET_STAND_ALONE */

  priv->icon = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
		  			 "accessories-dictionary",
					 48,
					 0,
					 NULL);
  
  /* force first draw */
  gdict_applet_draw (applet);

  /* force retrieval of the configuration from settings */
  gdict_applet_set_source_name (applet, NULL);
  gdict_applet_set_defbox_font (applet, NULL);
  gdict_applet_set_print_font (applet, NULL);
}
Example #8
0
gboolean
gs_plugin_add_distro_upgrades (GsPlugin *plugin,
			       GsAppList *list,
			       GCancellable *cancellable,
			       GError **error)
{
	GsPluginData *priv = gs_plugin_get_data (plugin);
	gsize len;
	guint i;
	g_autofree gchar *data = NULL;
	g_autoptr(GPtrArray) distros = NULL;
	g_autoptr(GSettings) settings = NULL;

	/* just ensure there is any data, no matter how old */
	if (!gs_plugin_fedora_distro_upgrades_refresh (plugin,
						       G_MAXUINT,
						       cancellable,
						       error))
		return FALSE;

	/* get cached file */
	if (!g_file_get_contents (priv->cachefn, &data, &len, error)) {
		gs_utils_error_convert_gio (error);
		return FALSE;
	}

	/* parse data */
	settings = g_settings_new ("org.gnome.software");
	distros = parse_pkgdb_collections_data (data, (gssize) len, error);
	if (distros == NULL)
		return FALSE;
	g_ptr_array_sort (distros, sort_distros_cb);
	for (i = 0; i < distros->len; i++) {
		DistroInfo *distro_info = g_ptr_array_index (distros, i);
		g_autofree gchar *app_id = NULL;
		g_autofree gchar *app_version = NULL;
		g_autofree gchar *background = NULL;
		g_autofree gchar *cache_key = NULL;
		g_autofree gchar *url = NULL;
		g_autofree gchar *css = NULL;
		g_autoptr(GsApp) app = NULL;
		g_autoptr(AsIcon) ic = NULL;

		/* only interested in upgrades to the same distro */
		if (g_strcmp0 (distro_info->name, priv->os_name) != 0)
			continue;

		/* only interested in newer versions, but not more than N+2 */
		if (distro_info->version <= priv->os_version ||
		    distro_info->version > priv->os_version + 2)
			continue;

		/* only interested in non-devel distros */
		if (!g_settings_get_boolean (settings, "show-upgrade-prerelease")) {
			if (distro_info->status == DISTRO_STATUS_DEVEL)
				continue;
		}

		/* search in the cache */
		cache_key = g_strdup_printf ("release-%u", distro_info->version);
		app = gs_plugin_cache_lookup (plugin, cache_key);
		if (app != NULL) {
			gs_app_list_add (list, app);
			continue;
		}

		app_id = g_strdup_printf ("org.fedoraproject.release-%u.upgrade",
					  distro_info->version);
		app_version = g_strdup_printf ("%u", distro_info->version);

		/* icon from disk */
		ic = as_icon_new ();
		as_icon_set_kind (ic, AS_ICON_KIND_LOCAL);
		as_icon_set_filename (ic, "/usr/share/pixmaps/fedora-logo-sprite.png");

		/* create */
		app = gs_app_new (app_id);
		gs_app_set_kind (app, AS_APP_KIND_OS_UPGRADE);
		gs_app_set_state (app, AS_APP_STATE_AVAILABLE);
		gs_app_set_name (app, GS_APP_QUALITY_LOWEST, distro_info->name);
		gs_app_set_summary (app, GS_APP_QUALITY_LOWEST,
		                    /* TRANSLATORS: this is a title for Fedora distro upgrades */
		                    _("A major upgrade, with new features and added polish."));
		gs_app_set_description (app, GS_APP_QUALITY_LOWEST,
		                        "Fedora Workstation is a polished, "
		                        "easy to use operating system for "
		                        "laptop and desktop computers, with a "
		                        "complete set of tools for developers "
		                        "and makers of all kinds.");
		gs_app_set_version (app, app_version);
		gs_app_set_size_installed (app, 1024 * 1024 * 1024); /* estimate */
		gs_app_set_size_download (app, 256 * 1024 * 1024); /* estimate */
		gs_app_set_license (app, GS_APP_QUALITY_LOWEST, "LicenseRef-free");
		gs_app_add_quirk (app, AS_APP_QUIRK_NEEDS_REBOOT);
		gs_app_add_quirk (app, AS_APP_QUIRK_PROVENANCE);
		gs_app_add_quirk (app, AS_APP_QUIRK_NOT_REVIEWABLE);
		gs_app_set_origin_ui (app, distro_info->name);
		gs_app_add_icon (app, ic);
		gs_app_set_management_plugin (app, "packagekit");

		/* show a Fedora magazine article for the release */
		url = g_strdup_printf ("https://fedoramagazine.org/whats-new-fedora-%u-workstation",
		                       distro_info->version);
		gs_app_set_url (app, AS_URL_KIND_HOMEPAGE, url);

		/* use a fancy background */
		background = get_upgrade_css_background (distro_info->version);
		css = g_strdup_printf ("background: %s;"
				       "background-position: center;"
				       "background-size: cover;",
				       background);
		gs_app_set_metadata (app, "GnomeSoftware::UpgradeBanner-css", css);

		gs_app_list_add (list, app);

		/* save in the cache */
		gs_plugin_cache_add (plugin, cache_key, app);
	}

	return TRUE;
}
Example #9
0
void
gdict_init (int *argc, char ***argv)
{
  GError *err = NULL;
  GOptionContext *context;
  gchar *loader_path;
  gchar **lookup_words = NULL;
  gchar **match_words = NULL;
  gchar *database = NULL;
  gchar *strategy = NULL;
  gchar *source_name = NULL;
  gboolean no_window = FALSE;
  gboolean list_sources = FALSE;

  const GOptionEntry gdict_app_goptions[] =
  {
    { "look-up", 0, 0, G_OPTION_ARG_STRING_ARRAY, &lookup_words,
       N_("Words to look up"), N_("word") },
    { "match", 0, 0, G_OPTION_ARG_STRING_ARRAY, &match_words,
       N_("Words to match"), N_("word") },
    { "source", 's', 0, G_OPTION_ARG_STRING, &source_name,
       N_("Dictionary source to use"), N_("source") },
    { "list-sources", 'l', 0, G_OPTION_ARG_NONE, &list_sources,
       N_("Show available dictionary sources"), NULL },
    { "no-window", 'n', 0, G_OPTION_ARG_NONE, &no_window,
       N_("Print result to the console"), NULL },
    { "database", 'D', 0, G_OPTION_ARG_STRING, &database,
       N_("Database to use"), N_("db") },
    { "strategy", 'S', 0, G_OPTION_ARG_STRING, &strategy,
       N_("Strategy to use"), N_("strat") },
    { G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_STRING_ARRAY, &lookup_words,
       N_("Words to look up"), N_("word") },
    { NULL },
  };
  
  g_assert (singleton == NULL);  
  
  singleton = GDICT_APP (g_object_new (GDICT_TYPE_APP, NULL));
  g_assert (GDICT_IS_APP (singleton));
  
  /* create the new option context */
  context = g_option_context_new (_(" - Look up words in dictionaries"));
  
  g_option_context_set_translation_domain (context, GETTEXT_PACKAGE);
  g_option_context_add_main_entries (context, gdict_app_goptions, GETTEXT_PACKAGE);
  g_option_context_add_group (context, gdict_get_option_group ());
  g_option_context_add_group (context, gtk_get_option_group (TRUE));

  g_option_context_parse (context, argc, argv, &err);
  if (err)
    {
      g_critical ("Failed to parse argument: %s", err->message);
      g_error_free (err);
      g_option_context_free (context);
      gdict_cleanup ();

      exit (1);
    }
  
  g_set_application_name (_("Dictionary"));
  gtk_window_set_default_icon_name ("accessories-dictionary");
  
  if (!gdict_create_data_dir ())
    {
      gdict_cleanup ();

      exit (1);
    }

  singleton->settings = g_settings_new ("org.mate.dictionary");

  /* add user's path for fetching dictionary sources */  
  singleton->loader = gdict_source_loader_new ();
  loader_path = gdict_get_data_dir (); 
  gdict_source_loader_add_search_path (singleton->loader, loader_path);
  g_free (loader_path);

  if (lookup_words)
    {
      gsize i;
      gsize length = g_strv_length (lookup_words);

      for (i = 0; i < length; i++)
	singleton->lookup_words = g_slist_prepend (singleton->lookup_words,
			                           g_strdup (lookup_words[i]));
    }

  if (match_words)
    {
      gsize i;
      gsize length = g_strv_length (match_words);

      for (i = 0; i < length; i++)
        singleton->match_words = g_slist_prepend (singleton->match_words,
			                          g_strdup (match_words[i]));
    }

  if (database)
    singleton->database = g_strdup (database);
  
  if (source_name)
    singleton->source_name = g_strdup (source_name);

  if (no_window)
    singleton->no_window = TRUE;

  if (list_sources)
    singleton->list_sources = TRUE;
}
static void
zoom_options_init (ZoomOptions *self)
{
  ZoomOptionsPrivate *priv;
  GtkWidget *w;
  PangoAttrList *pango_attrs;
  PangoAttribute *attr;
  GError *err = NULL;

  priv = self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, ZOOM_TYPE_OPTIONS, ZoomOptionsPrivate);

  priv->builder = gtk_builder_new ();
  gtk_builder_add_from_file (priv->builder,
                             CINNAMONCC_UI_DIR "/zoom-options.ui",
                             &err);
  if (err)
    {
      g_warning ("Could not load interface file: %s", err->message);
      g_error_free (err);

      g_object_unref (priv->builder);
      priv->builder = NULL;

      return;
    }

  priv->settings = g_settings_new ("org.gnome.desktop.a11y.magnifier");
  priv->application_settings = g_settings_new ("org.gnome.desktop.a11y.applications");

  pango_attrs = pango_attr_list_new ();
  attr = pango_attr_scale_new (FONT_SCALE);
  pango_attr_list_insert (pango_attrs, attr);

  /* Zoom switch */
  g_settings_bind (priv->application_settings, "screen-magnifier-enabled",
                   WID ("seeing_zoom_switch"), "active",
                   G_SETTINGS_BIND_DEFAULT);

  /* Magnification factor */
  w = WID ("magFactorSpinButton");
  g_settings_bind (priv->settings, "mag-factor",
                   gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (w)),
                   "value", G_SETTINGS_BIND_DEFAULT);

  /* Screen position combo */
  w = WID ("screen_position_combo_box");
  screen_position_notify_cb (priv->settings, "screen-position", self);
  g_signal_connect (G_OBJECT (priv->settings), "changed::screen-position",
                    G_CALLBACK (screen_position_notify_cb), self);
  g_signal_connect (G_OBJECT (w), "changed",
                    G_CALLBACK (screen_position_combo_changed_cb), self);

  /* Screen part section */
  init_screen_part_section (priv, pango_attrs);

  /* Cross hairs: show/hide ... */
  w = WID ("xhairsEnabledSwitch");
  g_settings_bind (priv->settings, "show-cross-hairs", w, "active",
                   G_SETTINGS_BIND_DEFAULT);

  /* ... Cross hairs: color and opacity */
  w = WID ("xHairsPicker");
  init_xhairs_color_opacity (GTK_COLOR_BUTTON (w), priv->settings);
  g_signal_connect (G_OBJECT (priv->settings), "changed::cross-hairs-color",
                    G_CALLBACK (xhairs_color_notify_cb), w);
  g_signal_connect (G_OBJECT (priv->settings), "changed::cross-hairs-opacity",
                    G_CALLBACK (xhairs_opacity_notify_cb), w);
  g_signal_connect (G_OBJECT (w), "color-set",
                    G_CALLBACK (xhairs_color_opacity_changed),
                    priv);

  /* ... Cross hairs: thickness ... */
  w = WID ("xHairsThicknessSlider");
  g_settings_bind (priv->settings, "cross-hairs-thickness",
                   gtk_range_get_adjustment (GTK_RANGE (w)), "value",
                   G_SETTINGS_BIND_DEFAULT);

  /* ... Cross hairs: clip ... */
  w = WID ("xHairsClipCheckbox");
  scale_label (GTK_BIN(w), pango_attrs);
  g_settings_bind (priv->settings, "cross-hairs-clip", w, "active",
                   G_SETTINGS_BIND_INVERT_BOOLEAN);

  /* ... Cross hairs: length ... */
  w = WID ("xHairsLengthSlider");
  xhairs_length_add_marks (GTK_SCALE (w));
  g_settings_bind (priv->settings, "cross-hairs-length",
                   gtk_range_get_adjustment (GTK_RANGE (w)), "value",
                   G_SETTINGS_BIND_DEFAULT);

  /* ... Color effects ... */
  w = WID ("inverseEnabledSwitch");
  g_settings_bind (priv->settings, "invert-lightness", w, "active",
                   G_SETTINGS_BIND_DEFAULT);

  w = WID ("brightnessSlider");
  priv->brightness_slider = w;
  init_effects_slider (GTK_RANGE(w), priv, brightness_keys,
                       G_CALLBACK (brightness_slider_notify_cb));

  w = WID ("contrastSlider");
  priv->contrast_slider = w;
  init_effects_slider (GTK_RANGE(w), priv, contrast_keys,
                       G_CALLBACK (contrast_slider_notify_cb));

  w = WID ("grayscale_slider");
  g_settings_bind (priv->settings, "color-saturation",
                   gtk_range_get_adjustment (GTK_RANGE (w)), "value",
                   G_SETTINGS_BIND_DEFAULT);
  gtk_scale_add_mark (GTK_SCALE(w), 1.0, GTK_POS_BOTTOM, NULL);
  /* ... Window itself ... */
  priv->dialog = WID ("magPrefsDialog");

  w = WID ("closeButton");
  g_signal_connect (G_OBJECT (w), "clicked",
                    G_CALLBACK (zoom_option_close_dialog_cb),
                    priv);
  g_signal_connect (G_OBJECT (priv->dialog), "delete-event",
                    G_CALLBACK (gtk_widget_hide_on_delete),
                    NULL);

  pango_attr_list_unref (pango_attrs);
}
Example #11
0
    extern GdkPixbuf *get_xformed_gdk_pixbuf(const char *path);
    /* Test({ */
    /*     const gchar *path = get_current_picture_path(); */
    /*     GdkPixbuf *pixbuf = get_xformed_gdk_pixbuf(path); */
    /*     g_object_unref(pixbuf); */
    /* }, "get_xformed_gdk_pixbuf"); */

    // on_bg_duration_tick Successful.
    extern gboolean on_bg_duration_tick(gpointer data);
    Test({
        on_bg_duration_tick(NULL);
    }, "on_bg_duration_tick");

    // bg_settings_picture_uri_changed
    GSettings *setting = NULL;
    setting = g_settings_new(BG_SCHEMA_ID);

    // haven't test.
    /* Test({ */
    /*     initial_setup(setting); */
    /* }, "initial_setup"); */

    // This function have never used.
    /* extern void bg_settings_picture_uri_changed(GSettings *setting, const gchar *key, gpointer data); */
    /* Test({ */
    /*     bg_settings_picture_uri_changed(setting, BG_PICTURE_URI, NULL); */
    /* }, "bg_settings_picture_uri_changed"); */

    // Test bg_settings_picture_uris_changed Successful.
    /* extern void bg_settings_picture_uris_changed (GSettings *settings, gchar *key, gpointer user_data); */
    /* Test({ */
Example #12
0
/* create the "add" dialog. */
void
add_folder_cb (GtkWidget *widget,
               void      *callback_data)
{
    GtkWidget   *file_sel;
    DialogData  *data;
    GtkWidget   *main_box;
    GtkWidget   *vbox;
    GtkWidget   *table;
    GtkWidget   *align;

    data = g_new0 (DialogData, 1);
    data->settings = g_settings_new (ENGRAMPA_SCHEMA_ADD);
    data->window = callback_data;

    data->dialog = file_sel =
                       gtk_file_chooser_dialog_new (_("Add a Folder"),
                               GTK_WINDOW (data->window),
                               GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
                               GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
                               FR_STOCK_ADD_FOLDER, GTK_RESPONSE_OK,
                               GTK_STOCK_HELP, GTK_RESPONSE_HELP,
                               NULL);

    gtk_window_set_default_size (GTK_WINDOW (data->dialog), 530, 510);

    gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER (file_sel), FALSE);
    gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (file_sel), FALSE);
    gtk_dialog_set_default_response (GTK_DIALOG (file_sel), GTK_RESPONSE_OK);

    data->add_if_newer_checkbutton = gtk_check_button_new_with_mnemonic (_("Add only if _newer"));
    data->include_subfold_checkbutton = gtk_check_button_new_with_mnemonic (_("_Include subfolders"));
    data->exclude_symlinks = gtk_check_button_new_with_mnemonic (_("Exclude folders that are symbolic lin_ks"));

    data->include_files_entry = gtk_entry_new ();
    gtk_widget_set_tooltip_text (data->include_files_entry, _("example: *.o; *.bak"));
    data->include_files_label = gtk_label_new_with_mnemonic (_("Include _files:"));
    gtk_misc_set_alignment (GTK_MISC (data->include_files_label), 0.0, 0.5);
    gtk_label_set_mnemonic_widget (GTK_LABEL (data->include_files_label), data->include_files_entry);

    data->exclude_files_entry = gtk_entry_new ();
    gtk_widget_set_tooltip_text (data->exclude_files_entry, _("example: *.o; *.bak"));
    data->exclude_files_label = gtk_label_new_with_mnemonic (_("E_xclude files:"));
    gtk_misc_set_alignment (GTK_MISC (data->exclude_files_label), 0.0, 0.5);
    gtk_label_set_mnemonic_widget (GTK_LABEL (data->exclude_files_label), data->exclude_files_entry);

    data->exclude_folders_entry = gtk_entry_new ();
    gtk_widget_set_tooltip_text (data->exclude_folders_entry, _("example: *.o; *.bak"));
    data->exclude_folders_label = gtk_label_new_with_mnemonic (_("_Exclude folders:"));
    gtk_misc_set_alignment (GTK_MISC (data->exclude_folders_label), 0.0, 0.5);
    gtk_label_set_mnemonic_widget (GTK_LABEL (data->exclude_folders_label), data->exclude_folders_entry);

    data->load_button = gtk_button_new_with_mnemonic (_("_Load Options"));
    data->save_button = gtk_button_new_with_mnemonic (_("Sa_ve Options"));
    data->clear_button = gtk_button_new_with_mnemonic (_("_Reset Options"));

    main_box = gtk_hbox_new (FALSE, 20);
    gtk_container_set_border_width (GTK_CONTAINER (main_box), 0);
    gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER (file_sel), main_box);

    vbox = gtk_vbox_new (FALSE, 6);
    gtk_container_set_border_width (GTK_CONTAINER (vbox), 0);
    gtk_box_pack_start (GTK_BOX (main_box), vbox, TRUE, TRUE, 0);

    gtk_box_pack_start (GTK_BOX (vbox), data->include_subfold_checkbutton,
                        TRUE, TRUE, 0);

    align = gtk_alignment_new (0, 0, 0, 0);
    gtk_alignment_set_padding (GTK_ALIGNMENT (align), 0, 0, 12, 0);
    gtk_container_add (GTK_CONTAINER (align), data->exclude_symlinks);
    gtk_box_pack_start (GTK_BOX (vbox), align, TRUE, TRUE, 0);

    gtk_box_pack_start (GTK_BOX (vbox), data->add_if_newer_checkbutton,
                        TRUE, TRUE, 0);

    table = gtk_table_new (2, 4, FALSE);
    gtk_table_set_row_spacings (GTK_TABLE (table), 6);
    gtk_table_set_col_spacings (GTK_TABLE (table), 6);
    gtk_box_pack_start (GTK_BOX (vbox), table,
                        TRUE, TRUE, 0);

    gtk_table_attach (GTK_TABLE (table),
                      data->include_files_label,
                      0, 1,
                      0, 1,
                      GTK_FILL, 0,
                      0, 0);
    gtk_table_attach (GTK_TABLE (table),
                      data->include_files_entry,
                      1, 4,
                      0, 1,
                      GTK_FILL|GTK_EXPAND, 0,
                      0, 0);
    gtk_table_attach (GTK_TABLE (table),
                      data->exclude_files_label,
                      0, 1,
                      1, 2,
                      GTK_FILL, 0,
                      0, 0);
    gtk_table_attach (GTK_TABLE (table),
                      data->exclude_files_entry,
                      1, 2,
                      1, 2,
                      GTK_FILL|GTK_EXPAND, 0,
                      0, 0);
    gtk_table_attach (GTK_TABLE (table),
                      data->exclude_folders_label,
                      2, 3,
                      1, 2,
                      GTK_FILL, 0,
                      0, 0);
    gtk_table_attach (GTK_TABLE (table),
                      data->exclude_folders_entry,
                      3, 4,
                      1, 2,
                      GTK_FILL|GTK_EXPAND, 0,
                      0, 0);

    /**/

    vbox = gtk_vbox_new (FALSE, 5);
    gtk_container_set_border_width (GTK_CONTAINER (vbox), 0);
    gtk_box_pack_start (GTK_BOX (main_box), vbox, FALSE, FALSE, 0);

    gtk_box_pack_start (GTK_BOX (vbox), data->load_button,
                        FALSE, FALSE, 0);
    gtk_box_pack_start (GTK_BOX (vbox), data->save_button,
                        FALSE, FALSE, 0);
    gtk_box_pack_start (GTK_BOX (vbox), data->clear_button,
                        FALSE, FALSE, 0);

    gtk_widget_show_all (main_box);

    /* set data */

    dlg_add_folder_load_last_options (data);

    /* signals */

    g_signal_connect (G_OBJECT (file_sel),
                      "destroy",
                      G_CALLBACK (open_file_destroy_cb),
                      data);
    g_signal_connect (G_OBJECT (file_sel),
                      "response",
                      G_CALLBACK (file_sel_response_cb),
                      data);
    g_signal_connect (G_OBJECT (data->include_subfold_checkbutton),
                      "toggled",
                      G_CALLBACK (include_subfold_toggled_cb),
                      data);
    g_signal_connect (G_OBJECT (data->load_button),
                      "clicked",
                      G_CALLBACK (load_options_cb),
                      data);
    g_signal_connect (G_OBJECT (data->save_button),
                      "clicked",
                      G_CALLBACK (save_options_cb),
                      data);
    g_signal_connect (G_OBJECT (data->clear_button),
                      "clicked",
                      G_CALLBACK (clear_options_cb),
                      data);

    gtk_window_set_modal (GTK_WINDOW (file_sel),TRUE);
    gtk_widget_show (file_sel);
}
Example #13
0
int main(int argc, char *argv[])
{
	UniqueApp *app;
	GtkStatusIcon *statusicon;
	GtkWidget *menu;
	GOptionContext *context;
	GError *error = NULL;

	bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR);
	bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
	textdomain(GETTEXT_PACKAGE);

	g_type_init ();

	/* Parse command-line options */
	context = g_option_context_new (N_("- Bluetooth applet"));
	g_option_context_set_translation_domain (context, GETTEXT_PACKAGE);
	g_option_context_add_main_entries (context, options, GETTEXT_PACKAGE);
	g_option_context_add_group (context, gtk_get_option_group (TRUE));
	if (g_option_context_parse (context, &argc, &argv, &error) == FALSE) {
		g_print (_("%s\nRun '%s --help' to see a full list of available command line options.\n"),
			 error->message, argv[0]);
		g_error_free (error);
		return 1;
	}

	if (option_debug == FALSE) {
		app = unique_app_new ("org.mate.Bluetooth.applet", NULL);
		if (unique_app_is_running (app)) {
			gdk_notify_startup_complete ();
			g_warning ("Applet is already running, exiting");
			return 0;
		}
	} else {
		app = NULL;
	}

	g_set_application_name(_("Bluetooth Applet"));

	gtk_window_set_default_icon_name("bluetooth");

	killswitch = bluetooth_killswitch_new ();
	g_signal_connect (G_OBJECT (killswitch), "state-changed",
			  G_CALLBACK (killswitch_state_changed), NULL);

	menu = create_popupmenu();

	client = bluetooth_client_new();

	devices_model = bluetooth_client_get_model(client);

	g_signal_connect(G_OBJECT(devices_model), "row-inserted",
			 G_CALLBACK(device_added), NULL);
	g_signal_connect(G_OBJECT(devices_model), "row-deleted",
			 G_CALLBACK(device_removed), NULL);
	g_signal_connect (G_OBJECT (devices_model), "row-changed",
			  G_CALLBACK (device_changed), NULL);

	/* Set the default adapter */
	device_changed (devices_model, NULL, NULL, NULL);
	if (bluetooth_killswitch_has_killswitches (killswitch) != FALSE) {
		killswitch_state_changed (killswitch,
					  bluetooth_killswitch_get_state (killswitch));
	}

	/* Make sure all the unblocked adapters are powered,
	 * so as to avoid seeing unpowered, but unblocked
	 * devices */
	bluetooth_set_adapter_powered ();

	settings = g_settings_new (SCHEMA_NAME);
	show_icon_pref = g_settings_get_boolean (settings, PREF_SHOW_ICON);

	g_signal_connect (G_OBJECT (settings), "changed::" PREF_SHOW_ICON,
			  G_CALLBACK (show_icon_changed), NULL);

	statusicon = init_notification();

	update_icon_visibility();

	g_signal_connect(statusicon, "activate",
				G_CALLBACK(activate_callback), menu);
	g_signal_connect(statusicon, "popup-menu",
				G_CALLBACK(popup_callback), menu);

	setup_agents();

	gtk_main();

	gtk_widget_destroy(menu);

	g_object_unref(settings);

	cleanup_agents();

	cleanup_notification();

	g_object_unref(devices_model);

	g_object_unref(client);

	if (app != NULL)
		g_object_unref (app);

	return 0;
}
Example #14
0
static void
dlg_extract__common (FrWindow *window,
	             GList    *selected_files,
	             char     *base_dir_for_selection)
{
	DialogData *data;
	GtkWidget  *file_sel;

	data = g_new0 (DialogData, 1);
	data->settings = g_settings_new (ENGRAMPA_SCHEMA_EXTRACT);
	data->window = window;
	data->selected_files = selected_files;
	data->base_dir_for_selection = base_dir_for_selection;
	data->extract_clicked = FALSE;

	data->dialog = file_sel =
		gtk_file_chooser_dialog_new (_("Extract"),
					     GTK_WINDOW (data->window),
					     GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
					     GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
					     FR_STOCK_EXTRACT, GTK_RESPONSE_OK,
					     GTK_STOCK_HELP, GTK_RESPONSE_HELP,
					     NULL);

	gtk_window_set_default_size (GTK_WINDOW (file_sel), 530, 510);

	gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER (file_sel), FALSE);
	gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (file_sel), FALSE);
	gtk_dialog_set_default_response (GTK_DIALOG (file_sel), GTK_RESPONSE_OK);

	gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER (file_sel), create_extra_widget (data));

	/* Set widgets data. */

	gtk_file_chooser_set_current_folder_uri (GTK_FILE_CHOOSER (file_sel), fr_window_get_extract_default_dir (window));

	if (data->selected_files != NULL)
		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (data->e_selected_radiobutton), TRUE);
	else {
		gtk_widget_set_sensitive (data->e_selected_radiobutton, FALSE);
		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (data->e_all_radiobutton), TRUE);
	}

	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (data->e_overwrite_checkbutton), g_settings_get_boolean (data->settings, PREF_EXTRACT_OVERWRITE));
	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (data->e_not_newer_checkbutton), g_settings_get_boolean (data->settings, PREF_EXTRACT_SKIP_NEWER));
	if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (data->e_overwrite_checkbutton))) {
		gtk_toggle_button_set_inconsistent (GTK_TOGGLE_BUTTON (data->e_not_newer_checkbutton), TRUE);
		gtk_widget_set_sensitive (data->e_not_newer_checkbutton, FALSE);
	}

	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (data->e_recreate_dir_checkbutton), g_settings_get_boolean (data->settings, PREF_EXTRACT_RECREATE_FOLDERS));


	/* Set the signals handlers. */

	g_signal_connect (G_OBJECT (data->dialog),
			  "destroy",
			  G_CALLBACK (destroy_cb),
			  data);

	g_signal_connect (G_OBJECT (file_sel),
			  "response",
			  G_CALLBACK (file_sel_response_cb),
			  data);

	g_signal_connect (G_OBJECT (data->e_overwrite_checkbutton),
			  "toggled",
			  G_CALLBACK (overwrite_toggled_cb),
			  data);
	g_signal_connect (G_OBJECT (data->e_files_entry),
			  "changed",
			  G_CALLBACK (files_entry_changed_cb),
			  data);

	/* Run dialog. */

	gtk_window_set_modal (GTK_WINDOW (file_sel),TRUE);
	gtk_widget_show (file_sel);
}
Example #15
0
/* Returns the GSettings* pointer to our preferences */
GSettings* get_prefs() {
	if(G_UNLIKELY(!prefs)) {
		prefs = g_settings_new("be.belgium.eid.eid-viewer");
	}
	return prefs;
}
static void
cc_date_time_panel_init (CcDateTimePanel *self)
{
  CcDateTimePanelPrivate *priv;
  GtkWidget *widget;
  GError *error;
  GtkTreeModelSort *city_modelsort;
  int ret;
  const char *date_grid_name;
  char *tmp;

  priv = self->priv = DATE_TIME_PANEL_PRIVATE (self);
  g_resources_register (cc_datetime_get_resource ());

  priv->cancellable = g_cancellable_new ();
  error = NULL;
  priv->dtm = timedate1_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
                                                G_DBUS_PROXY_FLAGS_NONE,
                                                "org.freedesktop.timedate1",
                                                "/org/freedesktop/timedate1",
                                                priv->cancellable,
                                                &error);
  if (priv->dtm == NULL) {
        g_warning ("could not get proxy for DateTimeMechanism: %s", error->message);
        g_clear_error (&error);
        return;
  }

  priv->builder = gtk_builder_new ();
  ret = gtk_builder_add_from_resource (priv->builder,
                                       "/org/gnome/control-center/datetime/datetime.ui",
                                       &error);

  if (ret == 0)
    {
      g_warning ("Could not load ui: %s", error ? error->message : "No reason");
      if (error)
        g_error_free (error);
      return;
    }

  switch (date_endian_get_default (FALSE)) {
  case DATE_ENDIANESS_BIG:
    date_grid_name = "big";
    break;
  case DATE_ENDIANESS_LITTLE:
    date_grid_name = "little";
    break;
  case DATE_ENDIANESS_MIDDLE:
    date_grid_name = "middle";
    break;
  case DATE_ENDIANESS_YDM:
    date_grid_name = "ydm";
    break;
  default:
    g_assert_not_reached ();
  }

  tmp = g_strdup_printf ("/org/gnome/control-center/datetime/%s.ui", date_grid_name);
  ret = gtk_builder_add_from_resource (priv->builder, tmp, NULL);
  g_free (tmp);

  gtk_box_pack_end (GTK_BOX (W ("time-box")), W ("date_grid"), FALSE, TRUE, 0);

  /* add the lock button */
  priv->permission = polkit_permission_new_sync (DATETIME_PERMISSION, NULL, NULL, NULL);
  if (priv->permission != NULL)
    {
      g_signal_connect (priv->permission, "notify",
                        G_CALLBACK (on_permission_changed), self);
      on_permission_changed (priv->permission, NULL, self);
    }
  else
    {
      g_warning ("Your system does not have the '%s' PolicyKit files installed. Please check your installation",
                 DATETIME_PERMISSION);
    }

  priv->date = g_date_time_new_now_local ();

  /* Top level windows from GtkBuilder that need to be destroyed explicitly */
  priv->toplevels = g_list_append (priv->toplevels, W ("datetime-dialog"));
  priv->toplevels = g_list_append (priv->toplevels, W ("timezone-dialog"));

  setup_timezone_dialog (self);
  setup_datetime_dialog (self);

  setup_listbox (self, W ("listbox1"));
  setup_listbox (self, W ("listbox2"));

  /* set up network time switch */
  bind_switch_to_row (self,
                      W ("network_time_switch"),
                      W ("datetime-button"));
  g_object_bind_property (priv->dtm, "ntp",
                          W ("network_time_switch"), "active",
                          G_BINDING_SYNC_CREATE);
  g_signal_connect (W("network_time_switch"), "notify::active",
                    G_CALLBACK (change_ntp), self);

  gtk_widget_set_visible (W ("auto-datetime-row"), is_ntp_available (self));

  /* Timezone settings */
  bind_switch_to_row (self,
                      W ("auto_timezone_switch"),
                      W ("timezone-button"));

  priv->datetime_settings = g_settings_new (DATETIME_SCHEMA);
  g_settings_bind (priv->datetime_settings, AUTO_TIMEZONE_KEY,
                   W ("auto_timezone_switch"), "active",
                   G_SETTINGS_BIND_DEFAULT);

  /* Clock settings */
  priv->clock_settings = g_settings_new (CLOCK_SCHEMA);

  widget = W ("vbox_datetime");
  gtk_container_add (GTK_CONTAINER (self), widget);

  /* setup the time itself */
  priv->clock_tracker = g_object_new (GNOME_TYPE_WALL_CLOCK, NULL);
  g_signal_connect (priv->clock_tracker, "notify::clock", G_CALLBACK (on_clock_changed), self);

  clock_settings_changed_cb (priv->clock_settings, CLOCK_FORMAT_KEY, self);
  g_signal_connect (priv->clock_settings, "changed::" CLOCK_FORMAT_KEY,
                    G_CALLBACK (clock_settings_changed_cb), self);

  g_signal_connect (W("format_combobox"), "notify::active-id",
                    G_CALLBACK (change_clock_settings), self);

  update_time (self);

  load_regions_model (GTK_LIST_STORE (gtk_builder_get_object (priv->builder,
                                                              "city-liststore")));

  city_modelsort = GTK_TREE_MODEL_SORT (gtk_builder_get_object (priv->builder, "city-modelsort"));
  gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (city_modelsort), CITY_COL_CITY_HUMAN_READABLE,
                                        GTK_SORT_ASCENDING);

  /* After the initial setup, so we can be sure that
   * the model is filled up */
  get_initial_timezone (self);

  widget = (GtkWidget*) gtk_builder_get_object (self->priv->builder,
                                                "timezone-searchentry");
  g_signal_connect (gtk_entry_get_completion (GTK_ENTRY (widget)),
                    "match-selected", G_CALLBACK (city_changed_cb), self);

  g_signal_connect (self->priv->map, "location-changed",
                    G_CALLBACK (location_changed_cb), self);

  /* Watch changes of timedated remote service properties */
  g_signal_connect (priv->dtm, "g-properties-changed",
                    G_CALLBACK (on_timedated_properties_changed), self);
  g_signal_connect_swapped (priv->dtm, "notify::can-ntp",
                            G_CALLBACK (on_can_ntp_changed), self);
  g_signal_connect_swapped (priv->dtm, "notify::timezone",
                            G_CALLBACK (on_timezone_changed), self);
  /* We ignore UTC <--> LocalRTC changes at the moment */

  priv->filechooser_settings = g_settings_new (FILECHOOSER_SCHEMA);
}
static void
cc_sharing_panel_setup_screen_sharing_dialog (CcSharingPanel *self)
{
  CcSharingPanelPrivate *priv = self->priv;
  GSettings *settings;
  GtkWidget *networks, *box, *w;

  cc_sharing_panel_bind_switch_to_widgets (WID ("require-password-radiobutton"),
                                           WID ("password-grid"),
                                           NULL);

  cc_sharing_panel_setup_label_with_hostname (self,
                                              WID ("screen-sharing-label"));

  /* settings bindings */
  settings = g_settings_new (VINO_SCHEMA_ID);
  g_settings_bind (settings, "view-only", WID ("remote-control-checkbutton"),
                   "active",
                   G_SETTINGS_BIND_DEFAULT | G_SETTINGS_BIND_INVERT_BOOLEAN);
  g_settings_bind (settings, "prompt-enabled",
                   WID ("approve-connections-radiobutton"), "active",
                   G_SETTINGS_BIND_DEFAULT);
  g_settings_bind_with_mapping (settings, "authentication-methods",
                                WID ("require-password-radiobutton"),
                                "active",
                                G_SETTINGS_BIND_DEFAULT,
                                vino_get_authtype, vino_set_authtype, NULL, NULL);

  g_settings_bind_with_mapping (settings, "vnc-password",
                                WID ("remote-control-password-entry"),
                                "text",
                                G_SETTINGS_BIND_DEFAULT,
                                vino_get_password, vino_set_password, NULL, NULL);

  g_object_bind_property (WID ("show-password-checkbutton"), "active",
                          WID ("remote-control-password-entry"), "visibility",
                          G_BINDING_SYNC_CREATE);

  /* make sure the password entry is hidden by default */
  g_signal_connect (priv->screen_sharing_dialog, "show",
                    G_CALLBACK (screen_sharing_show_cb), self);

  g_signal_connect (priv->screen_sharing_dialog, "hide",
                    G_CALLBACK (screen_sharing_hide_cb), self);

  /* accept at most 8 bytes in password entry */
  g_signal_connect (WID ("remote-control-password-entry"), "insert-text",
                    G_CALLBACK (screen_sharing_password_insert_text_cb), self);

  networks = cc_sharing_networks_new (self->priv->sharing_proxy, "vino-server");
  box = WID ("remote-control-box");
  gtk_box_pack_end (GTK_BOX (box), networks, TRUE, TRUE, 0);
  gtk_widget_show (networks);

  w = cc_sharing_switch_new (networks);
  gtk_header_bar_pack_start (GTK_HEADER_BAR (WID ("screen-sharing-headerbar")), w);
  self->priv->screen_sharing_switch = w;

  cc_sharing_panel_bind_networks_to_label (self, networks,
                                           WID ("screen-sharing-status-label"));
}