int main(int argc, char **argv) { XfconfChannel *channel; SignalTestData std = { NULL, FALSE }; std.mloop = g_main_loop_new(NULL, FALSE); if(!xfconf_tests_start()) return 2; channel = xfconf_channel_new(TEST_CHANNEL_NAME); xfconf_channel_reset_property (channel, test_string_property, FALSE); g_signal_connect(G_OBJECT(channel), "property-changed", G_CALLBACK(test_signal_changed), &std); TEST_OPERATION(xfconf_channel_set_string(channel, test_string_property, test_string)); g_timeout_add(1500, test_watchdog, &std); g_main_loop_run(std.mloop); g_main_loop_unref(std.mloop); g_object_unref(G_OBJECT(channel)); xfconf_tests_end(); return std.got_signal ? 0 : 1; }
static void xfce_xsettings_helper_init (XfceXSettingsHelper *helper) { helper->channel = xfconf_channel_new ("xsettings"); helper->settings = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, xfce_xsettings_helper_setting_free); xfce_xsettings_helper_load (helper); g_signal_connect (G_OBJECT (helper->channel), "property-changed", G_CALLBACK (xfce_xsettings_helper_prop_changed), helper); }
int main(int argc, char **argv) { XfconfChannel *channel; if(!xfconf_tests_start()) return 1; channel = xfconf_channel_new(TEST_CHANNEL_NAME); { gchar **strlist = xfconf_channel_get_string_list(channel, test_strlist_property); gint i; if(!strlist) { g_critical("Test failed: xfconf_channel_get_string_list() returned NULL"); xfconf_tests_end(); return 1; } for(i = 0; strlist[i] && test_strlist[i]; ++i) { if(strcmp(strlist[i], test_strlist[i])) { g_critical("Test failed: string list values don't match (%s != %s)", strlist[i], test_strlist[i]); xfconf_tests_end(); return 1; } } if(strlist[i] || test_strlist[i]) { g_critical("Test failed: in string list, element %d should be NULL (0x%p, 0x%p)", i, strlist[i], test_strlist[i]); xfconf_tests_end(); return 1; } g_strfreev(strlist); } g_object_unref(G_OBJECT(channel)); xfconf_tests_end(); return 0; }
int main(int argc, char **argv) { XfconfChannel *channel; if(!xfconf_tests_start()) return 1; channel = xfconf_channel_new(TEST_CHANNEL_NAME); TEST_OPERATION(xfconf_channel_set_int(channel, test_int_property, test_int)); g_object_unref(G_OBJECT(channel)); xfconf_tests_end(); return 0; }
gboolean migrate_46 (const gchar *filename, GError **error) { gsize length; gchar *contents; GMarkupParseContext *context; ConfigParser *parser; gboolean succeed = FALSE; g_return_val_if_fail (filename != NULL, FALSE); g_return_val_if_fail (error == NULL || *error == NULL, FALSE); if (!g_file_get_contents (filename, &contents, &length, error)) return FALSE; parser = g_slice_new0 (ConfigParser); parser->state = START; parser->plugin_id_counter = 0; parser->panel_id_counter = 0; parser->channel = xfconf_channel_new (XFCE_PANEL_CHANNEL_NAME); context = g_markup_parse_context_new (&markup_parser, 0, parser, NULL); if (g_markup_parse_context_parse (context, contents, length, error)) { /* check if the entire file is parsed */ if (g_markup_parse_context_end_parse (context, error)) succeed = TRUE; } /* if parsing failed somehow, empty the channel so no broken config is left */ if (!succeed) xfconf_channel_reset_property (parser->channel, "/", TRUE); g_free (contents); g_markup_parse_context_free (context); g_object_unref (G_OBJECT (parser->channel)); g_slice_free (ConfigParser, parser); return succeed; }
static void rstto_settings_init (GObject *object) { gchar *accelmap_path = NULL; RsttoSettings *settings = RSTTO_SETTINGS (object); settings->priv = g_new0 (RsttoSettingsPriv, 1); settings->priv->channel = xfconf_channel_new ("ristretto"); accelmap_path = xfce_resource_lookup (XFCE_RESOURCE_CONFIG, "ristretto/accels.scm"); if (accelmap_path) { gtk_accel_map_load (accelmap_path); g_free (accelmap_path); accelmap_path = NULL; } else { /* If the accels.scm file is missing, we are probably * dealing with a first-boot. Add default accelerators. */ gtk_accel_map_change_entry ("<Window>/fullscreen", GDK_KEY_F, 0, FALSE); gtk_accel_map_change_entry ("<Window>/unfullscreen", GDK_KEY_Escape, 0, FALSE); gtk_accel_map_change_entry ("<Window>/next-image", GDK_KEY_Page_Down, 0, FALSE); gtk_accel_map_change_entry ("<Window>/previous-image", GDK_KEY_Page_Up, 0, FALSE); gtk_accel_map_change_entry ("<Window>/quit", GDK_KEY_q, 0, FALSE); gtk_accel_map_change_entry ("<Window>/delete", GDK_KEY_Delete, GDK_SHIFT_MASK, FALSE); gtk_accel_map_change_entry ("<Window>/refresh", GDK_KEY_r, GDK_CONTROL_MASK, FALSE); gtk_accel_map_change_entry ("<Actions>/RsttoWindow/play", GDK_KEY_F5, 0, FALSE); } settings->priv->slideshow_timeout = 5; settings->priv->bgcolor = g_new0 (GdkColor, 1); settings->priv->bgcolor_fullscreen = g_new0 (GdkColor, 1); settings->priv->navigationbar_position = g_strdup ("left"); settings->priv->show_toolbar = TRUE; settings->priv->window_width = 600; settings->priv->window_height = 440; settings->priv->wrap_images = TRUE; settings->priv->show_thumbnailbar = TRUE; settings->priv->show_statusbar = TRUE; settings->priv->use_thunar_properties = TRUE; settings->priv->maximize_on_startup = TRUE; settings->priv->hide_thumbnails_fullscreen = TRUE; settings->priv->errors.missing_thumbnailer = TRUE; settings->priv->thumbnail_size = THUMBNAIL_SIZE_NORMAL; xfconf_g_property_bind ( settings->priv->channel, "/window/width", G_TYPE_UINT, settings, "window-width"); xfconf_g_property_bind ( settings->priv->channel, "/window/height", G_TYPE_UINT, settings, "window-height"); xfconf_g_property_bind ( settings->priv->channel, "/file/current-uri", G_TYPE_STRING, settings, "current-uri"); xfconf_g_property_bind ( settings->priv->channel, "/window/toolbar/show", G_TYPE_BOOLEAN, settings, "show-toolbar"); xfconf_g_property_bind ( settings->priv->channel, "/window/navigationbar/sort-type", G_TYPE_UINT, settings, "sort-type"); xfconf_g_property_bind ( settings->priv->channel, "/window/navigationbar/position", G_TYPE_STRING, settings, "navigationbar-position"); xfconf_g_property_bind ( settings->priv->channel, "/window/thumbnails/show", G_TYPE_BOOLEAN, settings, "show-thumbnailbar"); xfconf_g_property_bind ( settings->priv->channel, "/window/statusbar/show", G_TYPE_BOOLEAN, settings, "show-statusbar"); xfconf_g_property_bind ( settings->priv->channel, "/window/thumbnails/size", G_TYPE_UINT, settings, "thumbnail-size"); xfconf_g_property_bind ( settings->priv->channel, "/window/thumbnails/hide-fullscreen", G_TYPE_BOOLEAN, settings, "hide-thumbnails-fullscreen"); xfconf_g_property_bind ( settings->priv->channel, "/slideshow/timeout", G_TYPE_UINT, settings, "slideshow-timeout"); xfconf_g_property_bind ( settings->priv->channel, "/window/bgcolor-override", G_TYPE_BOOLEAN, settings, "bgcolor-override"); xfconf_g_property_bind_gdkcolor ( settings->priv->channel, "/window/bgcolor", settings, "bgcolor"); xfconf_g_property_bind_gdkcolor ( settings->priv->channel, "/window/bgcolor-fullscreen", settings, "bgcolor-fullscreen"); xfconf_g_property_bind ( settings->priv->channel, "/window/invert-zoom-direction", G_TYPE_BOOLEAN, settings, "invert-zoom-direction"); xfconf_g_property_bind ( settings->priv->channel, "/window/show-clock", G_TYPE_BOOLEAN, settings, "show-clock"); xfconf_g_property_bind ( settings->priv->channel, "/image/wrap", G_TYPE_BOOLEAN, settings, "wrap-images"); xfconf_g_property_bind ( settings->priv->channel, "/image/limit-quality", G_TYPE_BOOLEAN, settings, "limit-quality"); xfconf_g_property_bind ( settings->priv->channel, "/window/use-thunar-properties", G_TYPE_BOOLEAN, settings, "use-thunar-properties"); xfconf_g_property_bind ( settings->priv->channel, "/window/maximize-on-startup", G_TYPE_BOOLEAN, settings, "maximize-on-startup"); xfconf_g_property_bind ( settings->priv->channel, "/errors/missing-thumbnailer", G_TYPE_BOOLEAN, settings, "show-error-missing-thumbnailer"); xfconf_g_property_bind ( settings->priv->channel, "/desktop/type", G_TYPE_STRING, settings, "desktop-type"); }
gint main (gint argc, gchar **argv) { GObject *dialog, *plug_child; GtkWidget *plug; GtkBuilder *builder; GError *error = NULL; /* setup translation domain */ xfce_textdomain (GETTEXT_PACKAGE, LOCALEDIR, "UTF-8"); /* initialize Gtk+ */ if(!gtk_init_with_args (&argc, &argv, "", entries, PACKAGE, &error)) { if (G_LIKELY (error)) { /* print error */ g_print ("%s: %s.\n", G_LOG_DOMAIN, error->message); g_print (_("Type '%s --help' for usage."), G_LOG_DOMAIN); g_print ("\n"); /* cleanup */ g_error_free (error); } else { g_error ("Unable to open display."); } return EXIT_FAILURE; } /* check if we should print version information */ if (G_UNLIKELY (opt_version)) { g_print ("%s %s (Xfce %s)\n\n", G_LOG_DOMAIN, PACKAGE_VERSION, xfce_version_string ()); g_print ("%s\n", "Copyright (c) 2008-2011"); g_print ("\t%s\n\n", _("The Xfce development team. All rights reserved.")); g_print (_("Please report bugs to <%s>."), PACKAGE_BUGREPORT); g_print ("\n"); return EXIT_SUCCESS; } /* initialize xfconf */ if (!xfconf_init (&error)) { /* print error and exit */ g_error ("Failed to connect to xfconf daemon: %s.", error->message); g_error_free (error); return EXIT_FAILURE; } /* open the channels */ accessibility_channel = xfconf_channel_new ("accessibility"); session_channel = xfconf_channel_new ("xfce4-session"); /* hook to make sure the libxfce4ui library is linked */ if (xfce_titled_dialog_get_type () == 0) return EXIT_FAILURE; /* load the Gtk user-interface file */ builder = gtk_builder_new (); if (gtk_builder_add_from_string (builder, accessibility_dialog_ui, accessibility_dialog_ui_length, &error) != 0) { /* Configure widgets */ accessibility_settings_dialog_configure_widgets (builder); if (G_UNLIKELY (opt_socket_id == 0)) { /* Get the dialog widget */ dialog = gtk_builder_get_object (builder, "dialog"); g_signal_connect (dialog, "response", G_CALLBACK (accessibility_settings_dialog_response), NULL); gtk_window_present (GTK_WINDOW (dialog)); /* To prevent the settings dialog to be saved in the session */ gdk_set_sm_client_id ("FAKE ID"); gtk_main (); } else { /* Create plug widget */ plug = gtk_plug_new (opt_socket_id); g_signal_connect (plug, "delete-event", G_CALLBACK (gtk_main_quit), NULL); gtk_widget_show (plug); /* Stop startup notification */ gdk_notify_startup_complete (); /* Get plug child widget */ plug_child = gtk_builder_get_object (builder, "plug-child"); gtk_widget_reparent (GTK_WIDGET (plug_child), plug); gtk_widget_show (GTK_WIDGET (plug_child)); /* To prevent the settings dialog to be saved in the session */ gdk_set_sm_client_id ("FAKE ID"); /* Enter main loop */ gtk_main (); } } else { g_error ("Failed to load the UI file: %s.", error->message); g_error_free (error); } /* Release Builder */ g_object_unref (G_OBJECT (builder)); /* release the channels */ g_object_unref (G_OBJECT (accessibility_channel)); g_object_unref (G_OBJECT (session_channel)); /* shutdown xfconf */ xfconf_shutdown(); return EXIT_SUCCESS; }
gint main(gint argc, gchar **argv) { GtkWidget *dialog; GtkWidget *settings_editor; GtkWidget *plug; GError *error = NULL; /* setup translation domain */ xfce_textdomain (GETTEXT_PACKAGE, LOCALEDIR, "UTF-8"); /* initialize Gtk+ */ if (!gtk_init_with_args (&argc, &argv, "", option_entries, GETTEXT_PACKAGE, &error)) { if (G_LIKELY (error)) { /* print error */ g_print ("%s: %s.\n", G_LOG_DOMAIN, error->message); g_print (_("Type '%s --help' for usage."), G_LOG_DOMAIN); g_print ("\n"); /* cleanup */ g_error_free (error); } else { g_error ("Unable to open display."); } return EXIT_FAILURE; } /* print version information */ if (G_UNLIKELY (opt_version)) { g_print ("%s %s (Xfce %s)\n\n", G_LOG_DOMAIN, PACKAGE_VERSION, xfce_version_string ()); g_print ("%s\n", "Copyright (c) 2008-2011"); g_print ("\t%s\n\n", _("The Xfce development team. All rights reserved.")); g_print (_("Please report bugs to <%s>."), PACKAGE_BUGREPORT); g_print ("\n"); return EXIT_SUCCESS; } /* initialize xfconf */ if (G_UNLIKELY (!xfconf_init (&error))) { /* print error and leave */ g_critical ("Failed to connect to Xfconf daemon: %s", error->message); g_error_free (error); return EXIT_FAILURE; } channel = xfconf_channel_new ("xfce4-settings-editor"); settings_editor = xfce_settings_editor_box_new ( xfconf_channel_get_int (channel, "/last/paned-position", 180)); if (G_UNLIKELY (opt_socket_id == 0)) { dialog = xfce_titled_dialog_new_with_buttons (_("Settings Editor"), NULL, GTK_DIALOG_DESTROY_WITH_PARENT, "gtk-help", GTK_RESPONSE_HELP, "gtk-close", GTK_RESPONSE_OK, NULL); xfce_titled_dialog_set_subtitle (XFCE_TITLED_DIALOG (dialog), _("Customize settings stored by Xfconf")); gtk_window_set_icon_name (GTK_WINDOW (dialog), "preferences-system"); gtk_window_set_type_hint (GTK_WINDOW (dialog), GDK_WINDOW_TYPE_HINT_NORMAL); gtk_window_set_default_size (GTK_WINDOW (dialog), xfconf_channel_get_int (channel, "/last/window-width", 640), xfconf_channel_get_int (channel, "/last/window-height", 500)); gtk_container_add_with_properties( GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), settings_editor, "expand", TRUE, "fill", TRUE, NULL); g_signal_connect (dialog, "response", G_CALLBACK (settings_dialog_response), settings_editor); gtk_widget_show_all (dialog); } else { /* Create plug widget */ plug = gtk_plug_new (opt_socket_id); g_signal_connect (plug, "delete-event", G_CALLBACK (plug_delete_event), settings_editor); gtk_window_set_default_size (GTK_WINDOW (plug), xfconf_channel_get_int (channel, "/last/window-width", 640), xfconf_channel_get_int (channel, "/last/window-height", 500)); gtk_widget_show (plug); gtk_container_add (GTK_CONTAINER(plug), settings_editor); /* Stop startup notification */ gdk_notify_startup_complete (); gtk_widget_show (GTK_WIDGET (settings_editor)); } gtk_main (); g_object_unref(channel); /* shutdown xfconf */ xfconf_shutdown (); return EXIT_SUCCESS; }
static void wm_tweaks_dialog_configure_widgets (GtkBuilder *builder) { GtkWidget *vbox; GtkTreeIter iter; GtkListStore *list_store; GtkCellRenderer *renderer; XfconfChannel *xfwm4_channel = xfconf_channel_new ("xfwm4"); gchar *easy_click = NULL; gchar *activate_action = NULL; gchar *default_placement = NULL; gboolean modifier_set = FALSE; guint n; /* Cycling tab */ GtkWidget *cycle_workspaces_check = GTK_WIDGET (gtk_builder_get_object (builder, "cycle_workspaces_check")); GtkWidget *cycle_hidden_check = GTK_WIDGET (gtk_builder_get_object (builder, "cycle_hidden_check")); GtkWidget *cycle_minimum_check = GTK_WIDGET (gtk_builder_get_object (builder, "cycle_minimum_check")); GtkWidget *cycle_draw_frame = GTK_WIDGET (gtk_builder_get_object (builder, "cycle_draw_frame")); GtkWidget *cycle_tabwin_mode = GTK_WIDGET (gtk_builder_get_object (builder, "cycle_tabwin_mode")); /* Focus tab */ GtkWidget *prevent_focus_stealing_check = GTK_WIDGET (gtk_builder_get_object (builder, "prevent_focus_stealing_check")); GtkWidget *focus_hint_check = GTK_WIDGET (gtk_builder_get_object (builder, "focus_hint_check")); GtkWidget *activate_action_bring_option = GTK_WIDGET (gtk_builder_get_object (builder, "activate_action_bring_option")); GtkWidget *activate_action_switch_option = GTK_WIDGET (gtk_builder_get_object (builder, "activate_action_switch_option")); GtkWidget *activate_action_none_option = GTK_WIDGET (gtk_builder_get_object (builder, "activate_action_none_option")); /* Accessibility tab */ GtkWidget *easy_click_combo_box = GTK_WIDGET (gtk_builder_get_object (builder, "easy_click_combo_box")); GtkWidget *raise_with_any_button_check = GTK_WIDGET (gtk_builder_get_object (builder, "raise_with_any_button_check")); GtkWidget *borderless_maximize_check = GTK_WIDGET (gtk_builder_get_object (builder, "borderless_maximize_check")); GtkWidget *titleless_maximize_check = GTK_WIDGET (gtk_builder_get_object (builder, "titleless_maximize_check")); GtkWidget *tile_on_move_check = GTK_WIDGET (gtk_builder_get_object (builder, "tile_on_move_check")); GtkWidget *snap_resist_check = GTK_WIDGET (gtk_builder_get_object (builder, "snap_resist_check")); GtkWidget *urgent_blink = GTK_WIDGET (gtk_builder_get_object (builder, "urgent_blink")); GtkWidget *repeat_urgent_blink = GTK_WIDGET (gtk_builder_get_object (builder, "repeat_urgent_blink")); GtkWidget *mousewheel_rollup = GTK_WIDGET (gtk_builder_get_object (builder, "mousewheel_rollup")); /* Workspaces tab */ GtkWidget *scroll_workspaces_check = GTK_WIDGET (gtk_builder_get_object (builder, "scroll_workspaces_check")); GtkWidget *toggle_workspaces_check = GTK_WIDGET (gtk_builder_get_object (builder, "toggle_workspaces_check")); GtkWidget *wrap_layout_check = GTK_WIDGET (gtk_builder_get_object (builder, "wrap_layout_check")); GtkWidget *wrap_cycle_check = GTK_WIDGET (gtk_builder_get_object (builder, "wrap_cycle_check")); /* Placement tab */ GtkWidget *placement_ratio_scale = GTK_WIDGET (gtk_builder_get_object (builder, "placement_ratio_scale")); GtkWidget *placement_center_option = GTK_WIDGET (gtk_builder_get_object (builder, "placement_center_option")); GtkWidget *placement_mouse_option = GTK_WIDGET (gtk_builder_get_object (builder, "placement_mouse_option")); /* Compositing tab */ GtkWidget *use_compositing_check = GTK_WIDGET (gtk_builder_get_object (builder, "use_compositing_check")); GtkWidget *use_compositing_box = GTK_WIDGET (gtk_builder_get_object (builder, "use_compositing_box")); GtkWidget *unredirect_overlays_check = GTK_WIDGET (gtk_builder_get_object (builder, "unredirect_overlays_check")); GtkWidget *sync_to_vblank_check = GTK_WIDGET (gtk_builder_get_object (builder, "sync_to_vblank_check")); GtkWidget *cycle_preview_check = GTK_WIDGET (gtk_builder_get_object (builder, "cycle_preview_check")); GtkWidget *show_frame_shadow_check = GTK_WIDGET (gtk_builder_get_object (builder, "show_frame_shadow_check")); GtkWidget *show_popup_shadow_check = GTK_WIDGET (gtk_builder_get_object (builder, "show_popup_shadow_check")); GtkWidget *show_dock_shadow_check = GTK_WIDGET (gtk_builder_get_object (builder, "show_dock_shadow_check")); GtkWidget *frame_opacity_scale = GTK_WIDGET (gtk_builder_get_object (builder, "frame_opacity_scale")); GtkWidget *inactive_opacity_scale = GTK_WIDGET (gtk_builder_get_object (builder, "inactive_opacity_scale")); GtkWidget *move_opacity_scale = GTK_WIDGET (gtk_builder_get_object (builder, "move_opacity_scale")); GtkWidget *popup_opacity_scale = GTK_WIDGET (gtk_builder_get_object (builder, "popup_opacity_scale")); GtkWidget *resize_opacity_scale = GTK_WIDGET (gtk_builder_get_object (builder, "resize_opacity_scale")); /* Fill combo-box */ list_store = gtk_list_store_new (1, G_TYPE_STRING); easy_click = xfconf_channel_get_string (xfwm4_channel, "/general/easy_click", "Alt"); gtk_cell_layout_clear (GTK_CELL_LAYOUT (easy_click_combo_box)); renderer = gtk_cell_renderer_text_new (); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (easy_click_combo_box), renderer, TRUE); gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (easy_click_combo_box), renderer, "text", 0); gtk_combo_box_set_model (GTK_COMBO_BOX (easy_click_combo_box), GTK_TREE_MODEL (list_store)); for (n = 0; modifier_list[n]; n++) { gtk_list_store_append (list_store, &iter); gtk_list_store_set (list_store, &iter, 0, N_(modifier_list[n]), -1); if (!modifier_set && !strcmp (easy_click, modifier_list[n])) { gtk_combo_box_set_active (GTK_COMBO_BOX (easy_click_combo_box), n); modifier_set = TRUE; } } /* If not specified, set to "None" */ if (!modifier_set) gtk_combo_box_set_active (GTK_COMBO_BOX (easy_click_combo_box), 0); activate_action = xfconf_channel_get_string (xfwm4_channel, "/general/activate_action", "bring"); if (!strcmp (activate_action, "switch")) { gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (activate_action_bring_option), FALSE); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (activate_action_switch_option), TRUE); } if (!strcmp (activate_action, "none")) gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (activate_action_none_option), TRUE); default_placement = xfconf_channel_get_string (xfwm4_channel, "/general/placement_mode", "center"); if (!strcmp (default_placement, "mouse")) { gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (placement_center_option), FALSE); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (placement_mouse_option), TRUE); } /* not so easy properties */ g_signal_connect (G_OBJECT (activate_action_bring_option), "toggled", G_CALLBACK (cb_activate_action_bring_radio_toggled), xfwm4_channel); g_signal_connect (G_OBJECT (activate_action_switch_option), "toggled", G_CALLBACK (cb_activate_action_switch_radio_toggled), xfwm4_channel); g_signal_connect (G_OBJECT (activate_action_none_option), "toggled", G_CALLBACK (cb_activate_action_none_radio_toggled), xfwm4_channel); g_signal_connect (G_OBJECT (borderless_maximize_check), "toggled", G_CALLBACK (cb_borderless_maximize_button_toggled), titleless_maximize_check); g_signal_connect (G_OBJECT (placement_center_option), "toggled", G_CALLBACK (cb_activate_placement_center_radio_toggled), xfwm4_channel); g_signal_connect (G_OBJECT (placement_mouse_option), "toggled", G_CALLBACK (cb_activate_placement_mouse_radio_toggled), xfwm4_channel); g_signal_connect (G_OBJECT (use_compositing_check), "toggled", G_CALLBACK (cb_use_compositing_check_button_toggled), use_compositing_box); g_signal_connect (G_OBJECT (easy_click_combo_box), "changed", G_CALLBACK (cb_easy_click_combo_box_changed), xfwm4_channel); g_signal_connect (G_OBJECT (urgent_blink), "toggled", G_CALLBACK (cb_urgent_blink_button_toggled), repeat_urgent_blink); /* Bind easy properties */ /* Cycling tab */ xfconf_g_property_bind (xfwm4_channel, "/general/cycle_minimum", G_TYPE_BOOLEAN, (GObject *)cycle_minimum_check, "active"); xfconf_g_property_bind (xfwm4_channel, "/general/cycle_hidden", G_TYPE_BOOLEAN, (GObject *)cycle_hidden_check, "active"); xfconf_g_property_bind (xfwm4_channel, "/general/cycle_workspaces", G_TYPE_BOOLEAN, (GObject *)cycle_workspaces_check, "active"); xfconf_g_property_bind (xfwm4_channel, "/general/cycle_draw_frame", G_TYPE_BOOLEAN, (GObject *)cycle_draw_frame, "active"); xfconf_g_property_bind (xfwm4_channel, "/general/cycle_tabwin_mode", G_TYPE_INT, (GObject *)cycle_tabwin_mode, "active"); /* Focus tab */ xfconf_g_property_bind (xfwm4_channel, "/general/prevent_focus_stealing", G_TYPE_BOOLEAN, (GObject *)prevent_focus_stealing_check, "active"); xfconf_g_property_bind (xfwm4_channel, "/general/focus_hint", G_TYPE_BOOLEAN, (GObject *)focus_hint_check, "active"); /* Accessibility tab */ xfconf_g_property_bind (xfwm4_channel, "/general/raise_with_any_button", G_TYPE_BOOLEAN, (GObject *)raise_with_any_button_check, "active"); xfconf_g_property_bind (xfwm4_channel, "/general/borderless_maximize", G_TYPE_BOOLEAN, (GObject *)borderless_maximize_check, "active"); xfconf_g_property_bind (xfwm4_channel, "/general/titleless_maximize", G_TYPE_BOOLEAN, (GObject *)titleless_maximize_check, "active"); xfconf_g_property_bind (xfwm4_channel, "/general/tile_on_move", G_TYPE_BOOLEAN, (GObject *)tile_on_move_check, "active"); xfconf_g_property_bind (xfwm4_channel, "/general/snap_resist", G_TYPE_BOOLEAN, (GObject *)snap_resist_check, "active"); xfconf_g_property_bind (xfwm4_channel, "/general/urgent_blink", G_TYPE_BOOLEAN, (GObject *)urgent_blink, "active"); xfconf_g_property_bind (xfwm4_channel, "/general/repeat_urgent_blink", G_TYPE_BOOLEAN, (GObject *)repeat_urgent_blink, "active"); xfconf_g_property_bind (xfwm4_channel, "/general/mousewheel_rollup", G_TYPE_BOOLEAN, (GObject *)mousewheel_rollup, "active"); gtk_widget_set_sensitive (repeat_urgent_blink, gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (urgent_blink))); gtk_widget_set_sensitive (titleless_maximize_check, gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (borderless_maximize_check))); /* Workspaces tab */ xfconf_g_property_bind (xfwm4_channel, "/general/toggle_workspaces", G_TYPE_BOOLEAN, (GObject *)toggle_workspaces_check, "active"); xfconf_g_property_bind (xfwm4_channel, "/general/scroll_workspaces", G_TYPE_BOOLEAN, (GObject *)scroll_workspaces_check, "active"); xfconf_g_property_bind (xfwm4_channel, "/general/wrap_layout", G_TYPE_BOOLEAN, (GObject *)wrap_layout_check, "active"); xfconf_g_property_bind (xfwm4_channel, "/general/wrap_cycle", G_TYPE_BOOLEAN, (GObject *)wrap_cycle_check, "active"); /* Placement tab */ xfconf_g_property_bind (xfwm4_channel, "/general/placement_ratio", G_TYPE_INT, (GObject *) gtk_range_get_adjustment (GTK_RANGE (placement_ratio_scale)), "value"); /* Compositing tab */ xfconf_g_property_bind (xfwm4_channel, "/general/use_compositing", G_TYPE_BOOLEAN, (GObject *)use_compositing_check, "active"); xfconf_g_property_bind (xfwm4_channel, "/general/unredirect_overlays", G_TYPE_BOOLEAN, (GObject *)unredirect_overlays_check, "active"); #ifdef HAVE_LIBDRM xfconf_g_property_bind (xfwm4_channel, "/general/sync_to_vblank", G_TYPE_BOOLEAN, (GObject *)sync_to_vblank_check, "active"); #else gtk_widget_hide (sync_to_vblank_check); #endif xfconf_g_property_bind (xfwm4_channel, "/general/cycle_preview", G_TYPE_BOOLEAN, (GObject *)cycle_preview_check, "active"); xfconf_g_property_bind (xfwm4_channel, "/general/show_frame_shadow", G_TYPE_BOOLEAN, (GObject *)show_frame_shadow_check, "active"); xfconf_g_property_bind (xfwm4_channel, "/general/show_popup_shadow", G_TYPE_BOOLEAN, (GObject *)show_popup_shadow_check, "active"); xfconf_g_property_bind (xfwm4_channel, "/general/show_dock_shadow", G_TYPE_BOOLEAN, (GObject *)show_dock_shadow_check, "active"); xfconf_g_property_bind (xfwm4_channel, "/general/frame_opacity", G_TYPE_INT, (GObject *) gtk_range_get_adjustment (GTK_RANGE (frame_opacity_scale)), "value"); xfconf_g_property_bind (xfwm4_channel, "/general/resize_opacity", G_TYPE_INT, (GObject *) gtk_range_get_adjustment (GTK_RANGE (resize_opacity_scale)), "value"); xfconf_g_property_bind (xfwm4_channel, "/general/move_opacity", G_TYPE_INT, (GObject *) gtk_range_get_adjustment (GTK_RANGE (move_opacity_scale)), "value"); xfconf_g_property_bind (xfwm4_channel, "/general/inactive_opacity", G_TYPE_INT, (GObject *) gtk_range_get_adjustment (GTK_RANGE (inactive_opacity_scale)), "value"); xfconf_g_property_bind (xfwm4_channel, "/general/popup_opacity", G_TYPE_INT, (GObject *) gtk_range_get_adjustment (GTK_RANGE (popup_opacity_scale)), "value"); vbox = GTK_WIDGET (gtk_builder_get_object (builder, "main-vbox")); gtk_widget_show_all (vbox); g_free (easy_click); g_free (activate_action); }
int main (int argc, char **argv) { GtkWidget *dialog; XfpmUnique *unique; GError *error = NULL; DBusGConnection *bus; GHashTable *config_hash; gboolean has_battery; gboolean auth_suspend; gboolean auth_hibernate; gboolean can_suspend; gboolean can_hibernate; gboolean can_shutdown; gboolean has_lcd_brightness; gboolean has_sleep_button; gboolean has_hibernate_button; gboolean has_power_button; gboolean has_lid; gboolean start_xfpm_if_not_running; gboolean debug = FALSE; GdkNativeWindow socket_id = 0; gchar *device_id = NULL; XfconfChannel *channel; DBusGProxy *proxy; GOptionEntry option_entries[] = { { "socket-id", 's', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_INT, &socket_id, N_("Settings manager socket"), N_("SOCKET ID") }, { "device-id", 'd', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_STRING, &device_id, N_("Display a specific device by UpDevice object path"), N_("UpDevice object path") }, { "debug", '\0', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE, &debug, N_("Enable debugging"), NULL }, { NULL, }, }; xfce_textdomain(GETTEXT_PACKAGE, LOCALEDIR, "UTF-8"); if( !gtk_init_with_args (&argc, &argv, (gchar *)"", option_entries, (gchar *)PACKAGE, &error)) { if( error) { g_printerr("%s: %s.\n", G_LOG_DOMAIN, error->message); g_printerr(_("Type '%s --help' for usage."), G_LOG_DOMAIN); g_printerr("\n"); g_error_free(error); } else { g_error("Unable to open display."); } return EXIT_FAILURE; } bus = dbus_g_bus_get(DBUS_BUS_SESSION, &error); if ( error ) { g_error ("%s\n",error->message); } while ( !xfpm_dbus_name_has_owner (dbus_g_connection_get_connection(bus), "org.xfce.PowerManager") ) { g_print(_("Xfce power manager is not running")); g_print("\n"); start_xfpm_if_not_running = xfce_dialog_confirm (NULL, GTK_STOCK_EXECUTE, _("Run"), NULL, _("Xfce4 Power Manager is not running, do you want to launch it now?")); if ( start_xfpm_if_not_running ) { g_spawn_command_line_async("xfce4-power-manager",NULL); /* wait 2 seconds for xfpm to startup */ g_usleep ( 2 * 1000000 ); } else { /* continue without starting xfpm, this will probably error out */ break; } } unique = xfpm_unique_new ("org.xfce.PowerManager.Config"); if ( !xfpm_unique_app_is_running (unique) ) { if ( !xfconf_init(&error) ) { g_critical("xfconf init failed: %s using default settings\n", error->message); xfce_dialog_show_warning (NULL, _("Xfce Power Manager"), "%s", _("Failed to load power manager configuration, using defaults")); g_error_free (error); error = NULL; return EXIT_FAILURE; } #if !GLIB_CHECK_VERSION (2, 32, 0) if ( !g_thread_supported () ) g_thread_init (NULL); #endif dbus_g_thread_init (); channel = xfconf_channel_new(XFPM_CHANNEL_CFG); proxy = dbus_g_proxy_new_for_name(bus, "org.xfce.PowerManager", "/org/xfce/PowerManager", "org.xfce.Power.Manager"); xfpm_manager_dbus_client_get_config (proxy, &config_hash, &error); if ( error ) { g_critical ("Unable to get configuration information from xfce power manager: %s", error->message); xfce_dialog_show_error (NULL, error, "%s", _("Unable to connect to Xfce Power Manager")); g_error_free (error); return EXIT_FAILURE; } xfpm_debug_init (debug); has_battery = xfpm_string_to_bool (g_hash_table_lookup (config_hash, "has-battery")); has_lid = xfpm_string_to_bool (g_hash_table_lookup (config_hash, "has-lid")); can_suspend = xfpm_string_to_bool (g_hash_table_lookup (config_hash, "can-suspend")); can_hibernate = xfpm_string_to_bool (g_hash_table_lookup (config_hash, "can-hibernate")); auth_suspend = xfpm_string_to_bool (g_hash_table_lookup (config_hash, "auth-suspend")); auth_hibernate = xfpm_string_to_bool (g_hash_table_lookup (config_hash, "auth-hibernate")); has_lcd_brightness = xfpm_string_to_bool (g_hash_table_lookup (config_hash, "has-brightness")); has_sleep_button = xfpm_string_to_bool (g_hash_table_lookup (config_hash, "sleep-button")); has_power_button = xfpm_string_to_bool (g_hash_table_lookup (config_hash, "power-button")); has_hibernate_button = xfpm_string_to_bool (g_hash_table_lookup (config_hash, "hibernate-button")); can_shutdown = xfpm_string_to_bool (g_hash_table_lookup (config_hash, "can-shutdown")); g_hash_table_destroy (config_hash); dialog = xfpm_settings_dialog_new (channel, auth_suspend, auth_hibernate, can_suspend, can_hibernate, can_shutdown, has_battery, has_lcd_brightness, has_lid, has_sleep_button, has_hibernate_button, has_power_button, socket_id, device_id); g_signal_connect_swapped (unique, "ping-received", G_CALLBACK (gtk_window_present), dialog); gtk_main(); xfpm_dbus_release_name(dbus_g_connection_get_connection(bus), "org.xfce.PowerManager.Config"); dbus_g_connection_unref (bus); g_object_unref (proxy); g_object_unref (unique); return EXIT_SUCCESS; } return EXIT_SUCCESS; }
static void xfce_randr_populate (XfceRandr *randr, Display *xdisplay, GdkWindow *root_window) { GPtrArray *outputs; XRROutputInfo *output_info; XRRCrtcInfo *crtc_info; gint n; guint m, connected; guint *output_ids = NULL; XfconfChannel *display_channel = xfconf_channel_new ("displays"); g_return_if_fail (randr != NULL); g_return_if_fail (randr->priv != NULL); g_return_if_fail (randr->priv->resources != NULL); /* prepare the temporary cache */ outputs = g_ptr_array_new (); output_ids = g_malloc0 (randr->priv->resources->noutput * sizeof (guint)); /* walk the outputs */ connected = 0; for (n = 0; n < randr->priv->resources->noutput; ++n) { /* get the output info */ output_info = XRRGetOutputInfo (xdisplay, randr->priv->resources, randr->priv->resources->outputs[n]); /* forget about disconnected outputs */ if (output_info->connection != RR_Connected) { XRRFreeOutputInfo (output_info); continue; } else { output_ids[connected] = n; connected++; } /* cache it */ g_ptr_array_add (outputs, output_info); } /* migrate the temporary cache */ randr->noutput = outputs->len; randr->priv->output_info = (XRROutputInfo **) g_ptr_array_free (outputs, FALSE); /* allocate final space for the settings */ randr->mode = g_new0 (RRMode, randr->noutput); randr->priv->modes = g_new0 (XfceRRMode *, randr->noutput); randr->position = g_new0 (XfceOutputPosition, randr->noutput); randr->rotation = g_new0 (Rotation, randr->noutput); randr->rotations = g_new0 (Rotation, randr->noutput); randr->mirrored = g_new0 (gboolean, randr->noutput); randr->status = g_new0 (XfceOutputStatus, randr->noutput); randr->friendly_name = g_new0 (gchar *, randr->noutput); /* walk the connected outputs */ for (m = 0; m < randr->noutput; ++m) { /* fill in supported modes */ randr->priv->modes[m] = xfce_randr_list_supported_modes (randr->priv->resources, randr->priv->output_info[m]); #ifdef HAS_RANDR_ONE_POINT_THREE /* find the primary screen if supported */ if (randr->priv->has_1_3 && XRRGetOutputPrimary (xdisplay, GDK_WINDOW_XID (root_window)) == randr->priv->resources->outputs[output_ids[m]]) randr->status[m] = XFCE_OUTPUT_STATUS_PRIMARY; else #endif randr->status[m] = XFCE_OUTPUT_STATUS_SECONDARY; if (randr->priv->output_info[m]->crtc != None) { crtc_info = XRRGetCrtcInfo (xdisplay, randr->priv->resources, randr->priv->output_info[m]->crtc); randr->mode[m] = crtc_info->mode; randr->rotation[m] = crtc_info->rotation; randr->rotations[m] = crtc_info->rotations; randr->position[m].x = crtc_info->x; randr->position[m].y = crtc_info->y; XRRFreeCrtcInfo (crtc_info); } else { /* output disabled */ randr->mode[m] = None; randr->rotation[m] = RR_Rotate_0; randr->rotations[m] = xfce_randr_get_safe_rotations (randr, xdisplay, m); } /* fill in the name used by the UI */ randr->friendly_name[m] = xfce_randr_friendly_name (randr, m, output_ids[m]); /* Update display info, primary display may have changed. */ xfce_randr_save_output (randr, "Default", display_channel, m); /* Replace spaces with underscore in name for xfconf compatibility */ g_strcanon(randr->priv->output_info[m]->name, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_<>", '_'); } /* populate mirrored details */ xfce_randr_guess_relations (randr); g_free (output_ids); }