static void exitbutton_construct(XfcePanelPlugin *plugin) { ExitbuttonPlugin *exitbutton; /* setup translation domain */ xfce_textdomain(GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8"); /* create the plugin */ exitbutton = exitbutton_new(plugin); /* add the button to the panel */ gtk_container_add(GTK_CONTAINER (plugin), exitbutton->button); /* show the panel's right-click menu on this bitton */ xfce_panel_plugin_add_action_widget(plugin, exitbutton->button); /* connect plugin signals */ g_signal_connect(G_OBJECT(plugin), "free-data", G_CALLBACK(exitbutton_free), exitbutton); g_signal_connect(G_OBJECT(plugin), "save", G_CALLBACK(exitbutton_save), exitbutton); g_signal_connect(G_OBJECT(plugin), "size-changed", G_CALLBACK(exitbutton_size_changed), exitbutton); g_signal_connect(G_OBJECT(plugin), "orientation-changed", G_CALLBACK(exitbutton_orientation_changed), exitbutton); /* show the configure menu item and connect signal */ xfce_panel_plugin_menu_show_configure (plugin); g_signal_connect (G_OBJECT(plugin), "configure-plugin", G_CALLBACK(exitbutton_configure), exitbutton); /* show the about menu item and connect signal */ xfce_panel_plugin_menu_show_about (plugin); g_signal_connect (G_OBJECT(plugin), "about", G_CALLBACK(exitbutton_about), NULL); }
static void xfapplet_construct (XfcePanelPlugin *plugin) { int argc = 1; char *argv[] = { "xfce4-xfapplet-plugin", }; XfAppletPlugin *xap; xfce_textdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8"); matecomponent_ui_init (argv[0], VERSION, &argc, argv); xfapplet_cleanup_unused_mateconf_keys (); xap = xfapplet_new (plugin); xfapplet_setup_empty (xap); if (xfapplet_read_configuration (xap)) xfapplet_setup_full (xap); g_signal_connect (plugin, "free-data", G_CALLBACK (xfapplet_free), xap); g_signal_connect (plugin, "size-changed", G_CALLBACK (xfapplet_size_changed), xap); g_signal_connect (plugin, "screen-position-changed", G_CALLBACK (xfapplet_screen_position_changed), xap); g_signal_connect (plugin, "configure-plugin", G_CALLBACK (xfapplet_chooser_dialog), xap); g_signal_connect (plugin, "about", G_CALLBACK (xfapplet_about_dialog), xap); }
// initialization {{{ G_MODULE_EXPORT void xfce_control_class_init(ControlClass *cc) { xfce_textdomain(GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8"); /* these are required */ cc->name = "fsguard"; cc->caption = _("Free Space Checker"); cc->create_control = (CreateControlFunc)create_plugin_control; cc->free = plugin_free; cc->attach_callback = plugin_attach_callback; /* options; don't define if you don't have any ;) */ cc->read_config = plugin_read_config; cc->write_config = plugin_write_config; /* Don't use this function at all if you want xfce to * do the sizing. * Just define the set_size function to NULL, or rather, don't * set it to something else. */ cc->set_size = plugin_set_size; cc->set_orientation = plugin_set_orientation; cc->create_options = plugin_create_options; }
// XFCE4 functions to create and destroy plugin extern "C" void plugin_construct(XfcePanelPlugin* xfce_plugin) { // Don't eat up too much CPU if (nice(5) == -1) { std::cerr << "Unable to nice hardware-monitor-plugin: %s" << std::strerror(errno) << "\n"; } try { // Initialising GTK and GNOME canvas /* Testing not initialising GTK, as this isn't a standalone application * but a library? Otherwise seems to fail */ //Gtk::Main main(NULL, NULL); Gnome::Canvas::init(); // i18n xfce_textdomain(GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8"); // Actually creating the plugin Plugin *plugin = new Plugin(xfce_plugin); plugin->show(); } catch(const Glib::Error &ex) { // From helpers fatal_error(ex.what()); } }
G_MODULE_EXPORT GType parole_plugin_initialize (ParoleProviderPlugin *plugin) { xfce_textdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8"); sample_provider_register_type (plugin); return SAMPLE_TYPE_PROVIDER; }
static void clipman_construct (XfcePanelPlugin *plugin) { ClipmanPlugin *clipman; xfce_textdomain(GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8"); clipman = clipman_new (plugin); gtk_container_add (GTK_CONTAINER (plugin), clipman->button); xfce_panel_plugin_add_action_widget (plugin, clipman->button); g_signal_connect (plugin, "free-data", G_CALLBACK (clipman_free), clipman); g_signal_connect (plugin, "save", G_CALLBACK (clipman_save), clipman); g_signal_connect (plugin, "size-changed", G_CALLBACK (clipman_set_size), clipman); xfce_panel_plugin_menu_show_configure (plugin); g_signal_connect (plugin, "configure-plugin", G_CALLBACK (clipman_configure), clipman); }
/* create widgets and connect to signals */ static void quicklauncher_construct (XfcePanelPlugin *plugin) { t_quicklauncher *quicklauncher = quicklauncher_new(plugin); xfce_textdomain(GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8"); g_signal_connect (plugin, "orientation-changed", G_CALLBACK (quicklauncher_orientation_changed), quicklauncher); g_signal_connect (plugin, "size-changed", G_CALLBACK (quicklauncher_set_size), quicklauncher); g_signal_connect (plugin, "free-data", G_CALLBACK (quicklauncher_free_data), quicklauncher); g_signal_connect (plugin, "save", G_CALLBACK (quicklauncher_save), quicklauncher); xfce_panel_plugin_menu_show_configure (plugin); g_signal_connect (plugin, "configure-plugin", G_CALLBACK (quicklauncher_configure), quicklauncher); xfce_panel_plugin_menu_show_about(plugin); g_signal_connect (plugin, "about", G_CALLBACK (quicklauncher_about), quicklauncher); }
static gboolean eyes_control_new(Control *ctrl) { t_eyes *eyes; xfce_textdomain(GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8"); eyes = g_new0(t_eyes, 1); eyes->ebox = gtk_event_box_new (); gtk_widget_show(GTK_WIDGET(eyes->ebox)); eyes->align = gtk_alignment_new (0.0, 0.0, 1.0, 1.0); #if 0 /* vertical, old style */ eyes->align = gtk_alignment_new (0.0, 0.5, 1.0, 0.0); #endif gtk_widget_show(GTK_WIDGET(eyes->align)); gtk_container_add(GTK_CONTAINER(eyes->ebox), GTK_WIDGET(eyes->align)); gtk_container_add(GTK_CONTAINER(ctrl->base), GTK_WIDGET(eyes->ebox)); ctrl->data = (gpointer)eyes; ctrl->with_popup = FALSE; properties_load(eyes); setup_eyes(eyes); eyes_applet_fill(eyes); return(TRUE); }
int main (int argc, char **argv) { /* imported from xfsm-manager.c */ extern gint shutdown_type; xfce_textdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8"); /* install required signal handlers */ signal (SIGPIPE, SIG_IGN); gtk_init (&argc, &argv); /* fake a client id for the manager, so the legacy management does not * recognize us to be a session client. */ gdk_set_sm_client_id (xfsm_manager_generate_client_id (NULL)); initialize (argc, argv); xfsm_manager_restart (); gtk_main (); ice_cleanup (); return xfsm_shutdown (shutdown_type); }
static void windowck_construct(XfcePanelPlugin *plugin) { WindowckPlugin *wckp; GtkWidget *refresh; /* setup transation domain */ xfce_textdomain(GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8"); /* create the plugin */ wckp = windowck_new(plugin); /* add the ebox to the panel */ gtk_container_add(GTK_CONTAINER (plugin), wckp->ebox); /* show the panel's right-click menu on this ebox */ xfce_panel_plugin_add_action_widget(plugin, wckp->ebox); // Set event handling (icon & title clicks) g_signal_connect(G_OBJECT (wckp->ebox), "button-press-event", G_CALLBACK (on_title_pressed), wckp); g_signal_connect(G_OBJECT (wckp->ebox), "button-release-event", G_CALLBACK (on_title_released), wckp); g_signal_connect(G_OBJECT (wckp->icon->eventbox), "button-release-event", G_CALLBACK (on_icon_released), wckp); /* connect plugin signals */ g_signal_connect(G_OBJECT (plugin), "free-data", G_CALLBACK (windowck_free), wckp); g_signal_connect(G_OBJECT (plugin), "save", G_CALLBACK (windowck_save), wckp); g_signal_connect(G_OBJECT (plugin), "size-changed", G_CALLBACK (windowck_size_changed), wckp); g_signal_connect(G_OBJECT (plugin), "screen-position-changed", G_CALLBACK (windowck_screen_position_changed), wckp); g_signal_connect(G_OBJECT (plugin), "orientation-changed", G_CALLBACK (windowck_orientation_changed), wckp); /* show the configure menu item and connect signal */ xfce_panel_plugin_menu_show_configure(plugin); g_signal_connect(G_OBJECT (plugin), "configure-plugin", G_CALLBACK (windowck_configure), wckp); /* show the about menu item and connect signal */ xfce_panel_plugin_menu_show_about(plugin); g_signal_connect (G_OBJECT (plugin), "about", G_CALLBACK (wck_about), "windowck-plugin"); /* add custom menu items */ refresh = show_refresh_item (plugin); g_signal_connect (G_OBJECT (refresh), "activate", G_CALLBACK (on_refresh_item_activated), wckp); /* start tracking title size */ init_title(wckp); /* start tracking title text */ wckp->win = g_slice_new0 (WckUtils); init_wnck(wckp->win, wckp->prefs->only_maximized, wckp); }
int main (int argc, char **argv) { GtkWidget *dialog; gint i; gulong xid; gchar *title, *newstr; xfce_textdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8"); gtk_init (&argc, &argv); if (argc < 2) { g_print ("Wrong number of arguments\n"); return 1; } xid = strtoul (argv [1], NULL, 16); if (!xid) { g_print ("Invalid XID (%s)\n", argv [1]); return 1; } title = g_strdup (""); for (i = 2; i < argc; i++) { newstr = g_strdup_printf ("%s %s", title, argv[i]); g_free (title); title = newstr; } dialog = gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_WARNING, GTK_BUTTONS_YES_NO, _("This window might be busy and is not responding.\n" "Do you want to terminate the application?")); gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_NO); g_object_set (GTK_WIDGET (dialog), "secondary-text", title, NULL); gtk_window_set_title (GTK_WINDOW (dialog), _("Warning")); g_signal_connect (G_OBJECT (dialog), "realize", G_CALLBACK (on_realize), (gpointer) GINT_TO_POINTER (xid)); gtk_widget_realize (dialog); if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_YES) { g_print ("YES=0x%lx\n", xid); } else { g_print ("NO=0x%lx\n", xid); } return 0; }
static void xfce_xkb_construct (XfcePanelPlugin *plugin) { GtkWidget *configure_layouts; GtkIconTheme *theme; GtkWidget *image; GdkPixbuf *pixbuf; t_xkb *xkb = xkb_new (plugin); xfce_textdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8"); xfce_panel_plugin_set_small (plugin, TRUE); g_signal_connect (plugin, "orientation-changed", G_CALLBACK (xfce_xkb_orientation_changed), xkb); g_signal_connect (plugin, "size-changed", G_CALLBACK (xfce_xkb_set_size), xkb); g_signal_connect (plugin, "free-data", G_CALLBACK (xfce_xkb_free_data), xkb); g_signal_connect (plugin, "save", G_CALLBACK (xfce_xkb_save_config), xkb); xfce_panel_plugin_menu_show_configure (plugin); g_signal_connect (plugin, "configure-plugin", G_CALLBACK (xfce_xkb_configure), xkb); xfce_panel_plugin_menu_show_about (plugin); g_signal_connect (plugin, "about", G_CALLBACK (xfce_xkb_about), xkb); configure_layouts = gtk_menu_item_new_with_label (_("Keyboard settings")); theme = gtk_icon_theme_get_for_screen (gdk_screen_get_default()); pixbuf = gtk_icon_theme_load_icon (theme, "preferences-desktop-keyboard", GTK_ICON_SIZE_MENU, 0, NULL); if (pixbuf != NULL) { image = gtk_image_new (); gtk_image_set_from_pixbuf (GTK_IMAGE (image), pixbuf); gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (configure_layouts), image); g_object_unref (pixbuf); } gtk_widget_show (configure_layouts); xfce_panel_plugin_menu_insert_item (plugin, GTK_MENU_ITEM (configure_layouts)); g_signal_connect (G_OBJECT (configure_layouts), "activate", G_CALLBACK (xfce_xkb_configure_layout), NULL); }
static void fortune_fish_plugin_construct(XfcePanelPlugin *plugin) { fortune_fish_plugin *fish_plugin; xfce_textdomain(GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8"); fish_plugin = fortune_fish_plugin_new(plugin); /* Add the animation to the panel plugin. */ gtk_container_add(GTK_CONTAINER(plugin), fish_plugin->fish->ebox); xfce_panel_plugin_add_action_widget(plugin, fish_plugin->fish->ebox); }
G_MODULE_EXPORT void xfce_control_class_init (ControlClass * cc) { TRACE ("enters xfce_control_class_init"); xfce_textdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8"); cc->name = "mount-plugin"; cc->caption = _("mount/display devices"); cc->create_control = (CreateControlFunc) create_mounter_control; cc->attach_callback = mounter_attach_callback; cc->free = mounter_free; cc->read_config = mounter_read_config; cc->write_config = mounter_write_config; cc->create_options = mounter_create_options; cc->set_theme = NULL; /* cc->set_size = NULL; * cc->set_orientation = NULL; * cc->about = NULL; */ /* Additional API calls */ /* use if there should be only one instance per screen */ control_class_set_unique (cc, TRUE); /* use if the gmodule should not be unloaded * * (usually because of library issues) */ /*control_class_set_unloadable (cc, FALSE);*/ /* use to set an icon to represent the module * * (you could even update it when the theme changes) */ /* if (1) { GdkPixbuf *pixbuf; pixbuf = xfce_icon_theme_load (xfce_icon_theme_get_for_screen (NULL), "sampleicon.png", 48); if (pixbuf) { control_class_set_icon (cc, pixbuf); g_object_unref (pixbuf); } } */ TRACE ("leaves xfce_control_class_init"); }
static void bubblemon_construct (XfcePanelPlugin *plugin) { Bubblemon *base; xfce_textdomain( GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8"); base = create_gui(plugin); xfce_panel_plugin_menu_show_configure(plugin); g_signal_connect(plugin, "free-data", G_CALLBACK(plugin_destroy), base); g_signal_connect(plugin, "configure-plugin", G_CALLBACK(display_about_dialog), base); g_signal_connect(plugin, "size-changed", G_CALLBACK(plugin_reconfigure), base); g_signal_connect(plugin, "orientation-changed", G_CALLBACK(update_orientation), base); }
int main (int argc, char **argv) { GtkWidget *dialog; GError *error = NULL; /* setup translation domain */ xfce_textdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8"); /* setup application name */ g_set_application_name (_("Thunar Volume Manager Settings")); #ifdef G_ENABLE_DEBUG /* Do NOT remove this line for now. If something doesn't work, fix your code instead */ g_log_set_always_fatal (G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING); #endif /* initialize the threading system */ if (!g_thread_supported ()) g_thread_init (NULL); /* initialize GTK+ */ if (!gtk_init_with_args (&argc, &argv, NULL, NULL, GETTEXT_PACKAGE, &error)) { g_fprintf (stderr, "%s: %s.\n", g_get_prgname (), error->message); g_error_free (error); return EXIT_FAILURE; } /* initialize xfconf */ if (!xfconf_init (&error)) { g_fprintf (stderr, "%s: %s.\n", g_get_prgname (), error->message); g_error_free (error); return EXIT_FAILURE; } /* display the dialog */ dialog = tvm_preferences_dialog_new (); gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); /* free xfconf resources */ xfconf_shutdown (); return EXIT_SUCCESS; }
G_MODULE_EXPORT void xfce_control_class_init(ControlClass *cc) { cc->name = "xfce-mailwatch"; xfce_textdomain(GETTEXT_PACKAGE, LOCALEDIR, "UTF-8"); cc->caption = _("Mail Watcher"); cc->create_control = mailwatch_create; cc->read_config = mailwatch_read_config; cc->write_config = mailwatch_write_config; cc->create_options = mailwatch_create_options; cc->free = mailwatch_free; cc->attach_callback = mailwatch_attach_callback; cc->set_size = mailwatch_set_size; cc->set_orientation = NULL; }
static void power_manager_plugin_construct (XfcePanelPlugin *plugin) { PowerManagerPlugin *power_manager_plugin; xfce_textdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8"); /* create the plugin */ power_manager_plugin = power_manager_plugin_new (plugin); /* show the configure menu item and connect signal */ xfce_panel_plugin_menu_show_configure (plugin); g_signal_connect (G_OBJECT (plugin), "configure-plugin", G_CALLBACK (power_manager_plugin_configure), power_manager_plugin); /* add the ebox to the panel */ gtk_container_add (GTK_CONTAINER (plugin), power_manager_plugin->ebox); }
static void lightdash_construct (XfcePanelPlugin *plugin) { LightdashPlugin *lightdash; xfce_textdomain(GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8"); lightdash = lightdash_new (plugin); /* set translation domain */ // xfce_textdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8"); /* create initial window */ lightdash->lightdash_window = lightdash_window_new (NULL, !opt_collapsed, lightdash); xfce_panel_plugin_add_action_widget (plugin, lightdash->button); xfce_panel_plugin_menu_show_configure (plugin); g_signal_connect (G_OBJECT (plugin), "free-data", G_CALLBACK (lightdash_free), lightdash); g_signal_connect (G_OBJECT (plugin), "save", G_CALLBACK (lightdash_save), lightdash); g_signal_connect (G_OBJECT (lightdash->button), "toggled", G_CALLBACK (lightdash_button_clicked), lightdash); g_signal_connect (G_OBJECT (plugin), "size-changed", G_CALLBACK (lightdash_size_changed), lightdash); g_signal_connect (G_OBJECT (lightdash->lightdash_window), "unmap", G_CALLBACK (lightdash_window_unmap), lightdash); g_signal_connect (G_OBJECT (plugin), "configure-plugin", G_CALLBACK (lightdash_configure), lightdash); g_signal_connect (G_OBJECT (plugin), "remote-event", G_CALLBACK (lightdash_remote_event), lightdash); }
// initialization {{{ G_MODULE_EXPORT void xfce_control_class_init(ControlClass *cc) { xfce_textdomain(GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8"); /* these are required */ cc->name = "windowlist"; cc->caption = _("Windowlist"); cc->create_control = (CreateControlFunc)create_plugin_control; cc->free = plugin_free; cc->attach_callback = plugin_attach_callback; /* options; don't define if you don't have any ;) */ cc->read_config = plugin_read_config; cc->write_config = plugin_write_config; cc->create_options = plugin_create_options; }
G_MODULE_EXPORT void xfce_control_class_init (ControlClass * cc) { xfce_textdomain (GETTEXT_PACKAGE, LOCALEDIR, "UTF-8"); cc->name = "megahertz"; cc->caption = _("Megahertz"); cc->create_control = (CreateControlFunc) create_megahertz_control; cc->free = megahertz_free; cc->attach_callback = megahertz_attach_callback; cc->set_size = megahertz_set_size; // cc->create_options = megahertz_create_options; control_class_set_unique (cc, TRUE); }
G_MODULE_EXPORT void xfce_control_class_init(ControlClass *cc) { xfce_textdomain(GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8"); cc->name = "netload"; cc->caption = _("Netload"); cc->create_control = (CreateControlFunc)monitor_control_new; cc->free = monitor_free; cc->read_config = monitor_read_config; cc->write_config = monitor_write_config; cc->attach_callback = monitor_attach_callback; cc->create_options = monitor_create_options; cc->set_size = monitor_set_size; cc->set_orientation = monitor_set_orientation; }
G_MODULE_EXPORT void xfce_control_class_init (ControlClass * cc) { xfce_textdomain(GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8"); cc->name = "datetime"; cc->caption = _("Date and Time"); cc->create_control = (CreateControlFunc) create_datetime_control; cc->free = datetime_free; cc->read_config = datetime_read_config; cc->write_config = datetime_write_config; cc->attach_callback = datetime_attach_callback; cc->create_options = datetime_create_options; cc->set_orientation = datetime_set_orientation; cc->set_size = datetime_set_size; }
static void sample_construct (XfcePanelPlugin *plugin) { SamplePlugin *sample; /* setup transation domain */ xfce_textdomain(GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8"); /* create the plugin */ sample = sample_new (plugin); /* add the ebox to the panel */ gtk_container_add (GTK_CONTAINER (plugin), sample->ebox); /* show the panel's right-click menu on this ebox */ xfce_panel_plugin_add_action_widget (plugin, sample->ebox); /* connect plugin signals */ g_signal_connect (G_OBJECT (plugin), "free-data", G_CALLBACK (sample_free), sample); g_signal_connect (G_OBJECT (plugin), "save", G_CALLBACK (sample_save), sample); g_signal_connect (G_OBJECT (plugin), "size-changed", G_CALLBACK (sample_size_changed), sample); g_signal_connect (G_OBJECT (plugin), "orientation-changed", G_CALLBACK (sample_orientation_changed), sample); /* show the configure menu item and connect signal */ xfce_panel_plugin_menu_show_configure (plugin); g_signal_connect (G_OBJECT (plugin), "configure-plugin", G_CALLBACK (sample_configure), sample); /* show the about menu item and connect signal */ xfce_panel_plugin_menu_show_about (plugin); g_signal_connect (G_OBJECT (plugin), "about", G_CALLBACK (sample_about), NULL); }
/* Plugin initialization function */ G_MODULE_EXPORT void plugin_init(XfdashboardPlugin *self) { /* Set up localization */ xfce_textdomain(GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8"); /* Set plugin info */ xfdashboard_plugin_set_info(self, "flags", XFDASHBOARD_PLUGIN_FLAG_EARLY_INITIALIZATION, "name", _("Clock"), "description", _("Adds new a view showing a clock"), "author", "Stephan Haller <*****@*****.**>", NULL); /* Register GObject types of this plugin */ XFDASHBOARD_REGISTER_PLUGIN_TYPE(self, xfdashboard_clock_view); XFDASHBOARD_REGISTER_PLUGIN_TYPE(self, xfdashboard_clock_view_settings); /* Connect plugin action handlers */ g_signal_connect(self, "enable", G_CALLBACK(plugin_enable), NULL); g_signal_connect(self, "disable", G_CALLBACK(plugin_disable), NULL); g_signal_connect(self, "configure", G_CALLBACK(plugin_configure), NULL); }
int main (int argc, char **argv) { GDBusConnection *bus; GError *error = NULL; XfpmPowerManager *proxy; GOptionContext *octx; gboolean run = FALSE; gboolean quit = FALSE; gboolean config = FALSE; gboolean version = FALSE; gboolean reload = FALSE; gboolean no_daemon = FALSE; gboolean debug = FALSE; gboolean dump = FALSE; gchar *client_id = NULL; GOptionEntry option_entries[] = { { "run",'r', G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE, &run, NULL, NULL }, { "no-daemon",'\0' , G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE, &no_daemon, N_("Do not daemonize"), NULL }, { "debug",'\0' , G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE, &debug, N_("Enable debugging"), NULL }, { "dump",'\0' , G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE, &dump, N_("Dump all information"), NULL }, { "restart", '\0', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE, &reload, N_("Restart the running instance of Xfce power manager"), NULL}, { "customize", 'c', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE, &config, N_("Show the configuration dialog"), NULL }, { "quit", 'q', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE, &quit, N_("Quit any running xfce power manager"), NULL }, { "version", 'V', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE, &version, N_("Version information"), NULL }, { "sm-client-id", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_STRING, &client_id, NULL, NULL }, { NULL, }, }; /* Parse the options */ octx = g_option_context_new(""); g_option_context_set_ignore_unknown_options(octx, TRUE); g_option_context_add_main_entries(octx, option_entries, NULL); g_option_context_add_group(octx, xfce_sm_client_get_option_group(argc, argv)); /* We can't add the following command because it will invoke gtk_init before we have a chance to fork. g_option_context_add_group(octx, gtk_get_option_group(TRUE)); */ if(!g_option_context_parse(octx, &argc, &argv, &error)) { g_printerr(_("Failed to parse arguments: %s\n"), error->message); g_option_context_free(octx); g_error_free(error); return EXIT_FAILURE; } g_option_context_free(octx); if ( version ) show_version (); /* Fork if needed */ if ( dump == FALSE && debug == FALSE && no_daemon == FALSE && daemon(0,0) ) { g_critical ("Could not daemonize"); } /* Initialize */ xfce_textdomain (GETTEXT_PACKAGE, LOCALEDIR, "UTF-8"); g_set_application_name (PACKAGE_NAME); if (!gtk_init_check (&argc, &argv)) { if (G_LIKELY (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; } xfpm_debug_init (debug); bus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error); if ( error ) { xfce_dialog_show_error (NULL, error, "%s", _("Unable to get connection to the message bus session")); g_error ("%s: \n", error->message); } if ( quit ) { if (!xfpm_dbus_name_has_owner (bus, "org.xfce.PowerManager") ) { g_print (_("Xfce power manager is not running")); g_print ("\n"); return EXIT_SUCCESS; } else { proxy = xfpm_power_manager_proxy_new_sync (bus, G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES | G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS, "org.xfce.PowerManager", "/org/xfce/PowerManager", NULL, NULL); if ( !proxy ) { g_critical ("Failed to get proxy"); g_object_unref(bus); return EXIT_FAILURE; } xfpm_power_manager_call_quit_sync (proxy, NULL, &error); g_object_unref (proxy); if ( error) { g_critical ("Failed to send quit message %s:\n", error->message); g_error_free (error); } } return EXIT_SUCCESS; } if ( config ) { g_spawn_command_line_async ("xfce4-power-manager-settings", &error); if ( error ) { g_critical ("Failed to execute xfce4-power-manager-settings: %s", error->message); g_error_free (error); return EXIT_FAILURE; } return EXIT_SUCCESS; } if ( reload ) { if (!xfpm_dbus_name_has_owner (bus, "org.xfce.PowerManager") && !xfpm_dbus_name_has_owner (bus, "org.freedesktop.PowerManagement")) { g_print ("Xfce power manager is not running\n"); xfpm_start (bus, client_id, dump); } proxy = xfpm_power_manager_proxy_new_sync (bus, G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES | G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS, "org.xfce.PowerManager", "/org/xfce/PowerManager", NULL, NULL); if ( !proxy ) { g_critical ("Failed to get proxy"); g_object_unref (bus); return EXIT_FAILURE; } if ( !xfpm_power_manager_call_restart_sync (proxy, NULL, NULL) ) { g_critical ("Unable to send reload message"); g_object_unref (proxy); g_object_unref (bus); return EXIT_SUCCESS; } return EXIT_SUCCESS; } if (dump) { if (xfpm_dbus_name_has_owner (bus, "org.xfce.PowerManager")) { xfpm_dump_remote (bus); return EXIT_SUCCESS; } } if (xfpm_dbus_name_has_owner (bus, "org.freedesktop.PowerManagement") ) { g_print ("%s: %s\n", _("Xfce Power Manager"), _("Another power manager is already running")); } else if (xfpm_dbus_name_has_owner (bus, "org.xfce.PowerManager")) { g_print (_("Xfce power manager is already running")); g_print ("\n"); return EXIT_SUCCESS; } else { xfpm_start (bus, client_id, dump); } return EXIT_SUCCESS; }
gint xfce_shortcut_conflict_dialog (GtkWindow *parent, const gchar *owner, const gchar *other, const gchar *shortcut, const gchar *owner_action, const gchar *other_action, gboolean ignore_same_provider) { GdkModifierType modifiers; gboolean handled; gchar *other_action_name; gchar *other_button_text; gchar *owner_action_name; gchar *owner_button_text; gchar *secondary_text; gchar *shortcut_label; gchar *title; guint keyval; gint response; gint i; /* Default values */ response = GTK_RESPONSE_ACCEPT; handled = FALSE; /* Make sure to use the translations from libxfce4ui */ xfce_textdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8"); if (g_utf8_collate (owner, other) == 0 && ignore_same_provider) return GTK_RESPONSE_ACCEPT; /* Get the shortcut label */ gtk_accelerator_parse (shortcut, &keyval, &modifiers); shortcut_label = gtk_accelerator_get_label (keyval, modifiers); if (g_utf8_collate (owner, other) == 0 && g_utf8_collate (owner_action, other_action) == 0) { /* This shortcut already exists in the provider, we don't want it twice */ /* Warn the user */ xfce_dialog_show_warning (parent, _("Please use another key combination."), _("%s already triggers this action."), shortcut_label); return GTK_RESPONSE_REJECT; } title = g_strdup_printf (_("Conflicting actions for %s"), shortcut_label); for (i = 0; conflict_messages[i].message != NULL; ++i) if (g_utf8_collate (conflict_messages[i].owner_name, owner) == 0 && g_utf8_collate (conflict_messages[i].other_name, other) == 0) { if (owner_action == NULL) owner_action_name = NULL; else if (g_utf8_collate (owner, "xfwm4") == 0) { DBG ("Owner action %s is an xfwm4 action, get the string", owner_action); /* We need to get the human readable string of the action name */ owner_action_name = g_strdup (xfce_shortcuts_xfwm4_get_feature_name (owner_action)); } else owner_action_name = g_strdup(owner_action); DBG ("Owner action name: %s", owner_action_name); if (other_action == NULL) other_action_name = NULL; else if (g_utf8_collate (other, "xfwm4") == 0) { /* We need to get the human readable string of the action name */ other_action_name = g_strdup (xfce_shortcuts_xfwm4_get_feature_name (other_action)); } else other_action_name = g_strdup (other_action); secondary_text = g_strdup_printf (_(conflict_messages[i].message), other_action_name); owner_button_text = g_strdup_printf (_(conflict_messages[i].owner_button_text), owner_action_name); other_button_text = g_strdup_printf (_(conflict_messages[i].other_button_text), other_action_name); response = xfce_message_dialog (parent, title, GTK_STOCK_DIALOG_QUESTION, title, secondary_text, XFCE_BUTTON_TYPE_MIXED, NULL, owner_button_text, GTK_RESPONSE_ACCEPT, XFCE_BUTTON_TYPE_MIXED, NULL, other_button_text, GTK_RESPONSE_REJECT, NULL); g_free (other_button_text); g_free (owner_button_text); g_free (secondary_text); g_free (other_action_name); g_free (owner_action_name); g_free (shortcut_label); handled = TRUE; break; } if (G_UNLIKELY (!handled)) { xfce_message_dialog (parent, title, GTK_STOCK_DIALOG_ERROR, title, _("This shortcut is already being used for something else."), GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, NULL); response = GTK_RESPONSE_REJECT; } g_free (title); return response; }
int main (int argc, char **argv) { DBusGConnection *bus; GError *error = NULL; DBusGProxy *proxy; gboolean run = FALSE; gboolean quit = FALSE; gboolean config = FALSE; gboolean version = FALSE; gboolean reload = FALSE; gboolean no_daemon = FALSE; gboolean debug = FALSE; gboolean dump = FALSE; gchar *client_id = NULL; GOptionEntry option_entries[] = { { "run",'r', G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE, &run, NULL, NULL }, { "no-daemon",'\0' , G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE, &no_daemon, N_("Do not daemonize"), NULL }, { "debug",'\0' , G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE, &debug, N_("Enable debugging"), NULL }, { "dump",'\0' , G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE, &dump, N_("Dump all information"), NULL }, { "restart", '\0', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE, &reload, N_("Restart the running instance of Xfce power manager"), NULL}, { "customize", 'c', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE, &config, N_("Show the configuration dialog"), NULL }, { "quit", 'q', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE, &quit, N_("Quit any running xfce power manager"), NULL }, { "version", 'V', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE, &version, N_("Version information"), NULL }, { "sm-client-id", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_STRING, &client_id, NULL, NULL }, { NULL, }, }; #if !GLIB_CHECK_VERSION (2, 32, 0) if ( !g_thread_supported () ) g_thread_init (NULL); #endif dbus_g_thread_init (); xfce_textdomain (GETTEXT_PACKAGE, LOCALEDIR, "UTF-8"); g_set_application_name (PACKAGE_NAME); if (!gtk_init_with_args (&argc, &argv, (gchar *)"", option_entries, (gchar *)PACKAGE, &error)) { if (G_LIKELY (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; } if ( version ) { show_version (); } xfpm_debug_init (debug); if ( dump == FALSE && debug == FALSE && no_daemon == FALSE && daemon(0,0) ) { g_critical ("Could not daemonize"); } bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error); if ( error ) { xfce_dialog_show_error (NULL, error, "%s", _("Unable to get connection to the message bus session")); g_error ("%s: \n", error->message); } if ( quit ) { if (!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"); return EXIT_SUCCESS; } else { proxy = dbus_g_proxy_new_for_name (bus, "org.xfce.PowerManager", "/org/xfce/PowerManager", "org.xfce.Power.Manager"); if ( !proxy ) { g_critical ("Failed to get proxy"); dbus_g_connection_unref(bus); return EXIT_FAILURE; } xfpm_manager_dbus_client_quit (proxy , &error); g_object_unref (proxy); if ( error) { g_critical ("Failed to send quit message %s:\n", error->message); g_error_free (error); } } return EXIT_SUCCESS; } if ( config ) { g_spawn_command_line_async ("xfce4-power-manager-settings", &error); if ( error ) { g_critical ("Failed to execute xfce4-power-manager-settings: %s", error->message); g_error_free (error); return EXIT_FAILURE; } return EXIT_SUCCESS; } if ( reload ) { if (!xfpm_dbus_name_has_owner (dbus_g_connection_get_connection (bus), "org.xfce.PowerManager") && !xfpm_dbus_name_has_owner (dbus_g_connection_get_connection (bus), "org.freedesktop.PowerManagement")) { g_print ("Xfce power manager is not running\n"); xfpm_start (bus, client_id, dump); } proxy = dbus_g_proxy_new_for_name (bus, "org.xfce.PowerManager", "/org/xfce/PowerManager", "org.xfce.Power.Manager"); if ( !proxy ) { g_critical ("Failed to get proxy"); dbus_g_connection_unref (bus); return EXIT_FAILURE; } if ( !xfpm_manager_dbus_client_restart (proxy, NULL) ) { g_critical ("Unable to send reload message"); g_object_unref (proxy); dbus_g_connection_unref (bus); return EXIT_SUCCESS; } return EXIT_SUCCESS; } if (dump) { if (xfpm_dbus_name_has_owner (dbus_g_connection_get_connection (bus), "org.xfce.PowerManager")) { xfpm_dump_remote (bus); return EXIT_SUCCESS; } } if (xfpm_dbus_name_has_owner (dbus_g_connection_get_connection (bus), "org.freedesktop.PowerManagement") ) { g_print ("%s: %s\n", _("Xfce Power Manager"), _("Another power manager is already running")); } else if (xfpm_dbus_name_has_owner (dbus_g_connection_get_connection(bus), "org.xfce.PowerManager")) { g_print (_("Xfce power manager is already running")); g_print ("\n"); return EXIT_SUCCESS; } else { xfpm_start (bus, client_id, dump); } return EXIT_SUCCESS; }
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; }