static LightdashPlugin * lightdash_new (XfcePanelPlugin *plugin) { LightdashPlugin *lightdash; lightdash = panel_slice_new0 (LightdashPlugin); lightdash->plugin = plugin; lightdash->button_title = NULL; lightdash->show_desktop = DEFAULT_SHOW_DESKTOP; lightdash_read (lightdash); lightdash->button = xfce_panel_create_toggle_button (); lightdash->button_label = gtk_label_new (lightdash->button_title); lightdash->opacity = DEFAULT_OPACITY; gtk_container_add (GTK_CONTAINER (lightdash->button), (lightdash->button_label)); gtk_widget_show (lightdash->button_label); gtk_container_add (GTK_CONTAINER (plugin), lightdash->button); gtk_widget_show_all (lightdash->button); return lightdash; }
static TimeOutPlugin* time_out_new (XfcePanelPlugin *plugin) { TimeOutPlugin *time_out; GtkOrientation orientation; /* Allocate memory for the plugin structure */ time_out = panel_slice_new0 (TimeOutPlugin); /* Store pointer to the plugin */ time_out->plugin = plugin; /* Create lock screen */ time_out->lock_screen = time_out_lock_screen_new (); /* Connect to 'postpone' signal of the lock screen */ g_signal_connect (G_OBJECT (time_out->lock_screen), "postpone", G_CALLBACK (time_out_postpone), time_out); /* Connect to 'resume' signal of the lock screen */ g_signal_connect (G_OBJECT (time_out->lock_screen), "resume", G_CALLBACK (time_out_resume), time_out); /* Create countdowns */ time_out->break_countdown = time_out_countdown_new (); time_out->lock_countdown = time_out_countdown_new (); /* Connect to break countdown signals */ g_signal_connect (G_OBJECT (time_out->break_countdown), "update", G_CALLBACK (time_out_break_countdown_update), time_out); g_signal_connect (G_OBJECT (time_out->break_countdown), "finish", G_CALLBACK (time_out_break_countdown_finish), time_out); /* Connect to lock countdown signals */ g_signal_connect (G_OBJECT (time_out->lock_countdown), "update", G_CALLBACK (time_out_lock_countdown_update), time_out); g_signal_connect (G_OBJECT (time_out->lock_countdown), "finish", G_CALLBACK (time_out_lock_countdown_finish), time_out); /* Get the current orientation */ orientation = xfce_panel_plugin_get_orientation (plugin); /* Create event box to catch user events */ time_out->ebox = gtk_event_box_new (); gtk_event_box_set_visible_window(GTK_EVENT_BOX(time_out->ebox), FALSE); gtk_widget_show (time_out->ebox); /* Create flexible box which can do both, horizontal and vertical layout */ time_out->hvbox = xfce_hvbox_new (orientation, FALSE, 2); gtk_container_add (GTK_CONTAINER (time_out->ebox), time_out->hvbox); gtk_widget_show (time_out->hvbox); /* Create time out icon */ time_out->panel_icon = gtk_image_new_from_icon_name ("xfce4-time-out-plugin", GTK_ICON_SIZE_DIALOG); gtk_image_set_pixel_size (GTK_IMAGE (time_out->panel_icon), xfce_panel_plugin_get_size (time_out->plugin) - 8); gtk_box_pack_start (GTK_BOX (time_out->hvbox), time_out->panel_icon, TRUE, TRUE, 0); gtk_widget_show (time_out->panel_icon); /* Create label for displaying the remaining time until the next break */ time_out->time_label = gtk_label_new (_("Inactive")); gtk_misc_set_alignment (GTK_MISC (time_out->time_label), 0.5, 0.5); gtk_box_pack_start (GTK_BOX (time_out->hvbox), time_out->time_label, TRUE, TRUE, 0); gtk_widget_show (time_out->time_label); return time_out; }
/** * construct_workspaces: * @plugin: the xfce plugin object * * Create the plugin. * * Returns: the plugin */ static i3WorkspacesPlugin * construct_workspaces(XfcePanelPlugin *plugin) { i3WorkspacesPlugin *i3_workspaces; GtkOrientation orientation; /* allocate memory for the plugin structure */ i3_workspaces = panel_slice_new0(i3WorkspacesPlugin); /* pointer to plugin */ i3_workspaces->plugin = plugin; /* plugin configuration */ i3_workspaces->config = i3_workspaces_config_new(); i3_workspaces_config_load(i3_workspaces->config, plugin); /* get the current orientation */ orientation = xfce_panel_plugin_get_orientation (plugin); /* create some panel widgets */ i3_workspaces->ebox = gtk_event_box_new(); gtk_widget_show(i3_workspaces->ebox); /* listen for scroll events */ gtk_widget_add_events(i3_workspaces->ebox, GDK_SCROLL_MASK); g_signal_connect(G_OBJECT(i3_workspaces->ebox), "scroll-event", G_CALLBACK(on_workspace_scrolled), i3_workspaces); i3_workspaces->hvbox = xfce_hvbox_new(orientation, FALSE, 2); gtk_widget_show(i3_workspaces->hvbox); gtk_container_add(GTK_CONTAINER(i3_workspaces->ebox), i3_workspaces->hvbox); i3_workspaces->workspace_buttons = g_hash_table_new(g_direct_hash, g_direct_equal); GError *err = NULL; i3_workspaces->i3wm = i3wm_construct(&err); if (NULL != err) { //TODO: error_state_on(); recover_from_disconnect(i3_workspaces); //TODO: error_state_off(); } connect_callbacks(i3_workspaces); add_workspaces(i3_workspaces); return i3_workspaces; }
static PowerManagerPlugin * power_manager_plugin_new (XfcePanelPlugin *plugin) { PowerManagerPlugin *power_manager_plugin; /* allocate memory for the plugin structure */ power_manager_plugin = panel_slice_new0 (PowerManagerPlugin); /* pointer to plugin */ power_manager_plugin->plugin = plugin; /* create some panel ebox */ power_manager_plugin->ebox = gtk_event_box_new (); gtk_widget_show (power_manager_plugin->ebox); gtk_event_box_set_visible_window (GTK_EVENT_BOX(power_manager_plugin->ebox), FALSE); power_manager_plugin->power_manager_button = power_manager_button_new (plugin); power_manager_button_show(POWER_MANAGER_BUTTON(power_manager_plugin->power_manager_button)); gtk_container_add (GTK_CONTAINER (power_manager_plugin->ebox), power_manager_plugin->power_manager_button); return power_manager_plugin; }
static SamplePlugin * sample_new (XfcePanelPlugin *plugin) { SamplePlugin *sample; GtkOrientation orientation; GtkWidget *label; /* allocate memory for the plugin structure */ sample = panel_slice_new0 (SamplePlugin); /* pointer to plugin */ sample->plugin = plugin; /* read the user settings */ sample_read (sample); /* get the current orientation */ orientation = xfce_panel_plugin_get_orientation (plugin); /* create some panel widgets */ sample->ebox = gtk_event_box_new (); gtk_widget_show (sample->ebox); sample->hvbox = gtk_box_new (orientation, 2); gtk_widget_show (sample->hvbox); gtk_container_add (GTK_CONTAINER (sample->ebox), sample->hvbox); /* some sample widgets */ label = gtk_label_new (_("Sample")); gtk_widget_show (label); gtk_box_pack_start (GTK_BOX (sample->hvbox), label, FALSE, FALSE, 0); label = gtk_label_new (_("Plugin")); gtk_widget_show (label); gtk_box_pack_start (GTK_BOX (sample->hvbox), label, FALSE, FALSE, 0); return sample; }
static i3WorkspacesPlugin * i3_workspaces_new (XfcePanelPlugin *plugin) { i3WorkspacesPlugin *i3_workspaces; GtkOrientation orientation; GtkWidget *label; /* allocate memory for the plugin structure */ i3_workspaces = panel_slice_new0 (i3WorkspacesPlugin); /* pointer to plugin */ i3_workspaces->plugin = plugin; /* get the current orientation */ orientation = xfce_panel_plugin_get_orientation (plugin); /* create some panel widgets */ i3_workspaces->ebox = gtk_event_box_new (); gtk_widget_show (i3_workspaces->ebox); i3_workspaces->hvbox = xfce_hvbox_new (orientation, FALSE, 2); gtk_widget_show (i3_workspaces->hvbox); gtk_container_add (GTK_CONTAINER (i3_workspaces->ebox), i3_workspaces->hvbox); i3_workspaces->i3wm = i3wm_construct(); i3_workspaces->buttons = (GtkWidget **) g_malloc0(sizeof(GtkWidget *) * I3_WORKSPACE_N); i3wm_set_workspace_created_callback(i3_workspaces->i3wm, i3_on_workspace_created, i3_workspaces); i3wm_set_workspace_destroyed_callback(i3_workspaces->i3wm, i3_on_workspace_destroyed, i3_workspaces); i3wm_set_workspace_focused_callback(i3_workspaces->i3wm, i3_on_workspace_focused, i3_workspaces); i3wm_set_workspace_blurred_callback(i3_workspaces->i3wm, i3_on_workspace_blurred, i3_workspaces); i3_add_workspaces(i3_workspaces); return i3_workspaces; }
static t_xkb * xkb_new (XfcePanelPlugin *plugin) { t_xkb *xkb; gchar *filename; WnckScreen *wnck_screen; xkb = panel_slice_new0 (t_xkb); xkb->plugin = plugin; filename = xfce_panel_plugin_lookup_rc_file (plugin); if ((!filename) || (!xkb_load_config (xkb, filename))) { xkb_load_default (xkb); } g_free (filename); xkb->btn = gtk_button_new (); gtk_button_set_relief (GTK_BUTTON (xkb->btn), GTK_RELIEF_NONE); gtk_container_add (GTK_CONTAINER (xkb->plugin), xkb->btn); xfce_panel_plugin_add_action_widget (xkb->plugin, xkb->btn); xkb->button_state = GTK_STATE_NORMAL; gtk_widget_show (xkb->btn); g_signal_connect (xkb->btn, "clicked", G_CALLBACK (xkb_plugin_button_clicked), xkb); g_signal_connect (xkb->btn, "scroll-event", G_CALLBACK (xkb_plugin_button_scrolled), NULL); g_object_set (G_OBJECT (xkb->btn), "has-tooltip", TRUE, NULL); g_signal_connect (xkb->btn, "query-tooltip", G_CALLBACK (xkb_plugin_set_tooltip), xkb); g_signal_connect (G_OBJECT (xkb->btn), "enter-notify-event", G_CALLBACK (xkb_plugin_button_entered), xkb); g_signal_connect (G_OBJECT (xkb->btn), "leave-notify-event", G_CALLBACK (xkb_plugin_button_left), xkb); g_signal_connect (G_OBJECT (xkb->btn), "size-allocate", G_CALLBACK (xkb_plugin_button_size_allocated), xkb); xkb->layout_image = gtk_image_new (); gtk_container_add (GTK_CONTAINER (xkb->btn), xkb->layout_image); g_signal_connect (G_OBJECT (xkb->layout_image), "expose-event", G_CALLBACK (xkb_plugin_layout_image_exposed), xkb); gtk_widget_show (GTK_WIDGET (xkb->layout_image)); if (xkb_config_initialize (xkb->group_policy, xkb_state_changed, xkb)) { xkb_refresh_gui (xkb); xkb_populate_popup_menu (xkb); } wnck_screen = wnck_screen_get_default (); g_signal_connect (G_OBJECT (wnck_screen), "active-window-changed", G_CALLBACK (xkb_plugin_active_window_changed), xkb); g_signal_connect (G_OBJECT (wnck_screen), "window-closed", G_CALLBACK (xkb_plugin_window_closed), xkb); g_signal_connect (G_OBJECT (wnck_screen), "application-closed", G_CALLBACK (xkb_plugin_application_closed), xkb); return xkb; }