static void pager_update(PagerData* pager) { wnck_pager_set_orientation(WNCK_PAGER(pager->pager), pager->orientation); wnck_pager_set_n_rows(WNCK_PAGER(pager->pager), pager->n_rows); wnck_pager_set_show_all(WNCK_PAGER(pager->pager), pager->display_all); if (pager->wm == PAGER_WM_MARCO) wnck_pager_set_display_mode(WNCK_PAGER(pager->pager), pager->display_mode); else wnck_pager_set_display_mode(WNCK_PAGER(pager->pager), WNCK_PAGER_DISPLAY_CONTENT); }
static void pager_update (PagerData *pager) { wnck_pager_set_orientation (WNCK_PAGER (pager->pager), pager->orientation); wnck_pager_set_n_rows (WNCK_PAGER (pager->pager), pager->n_rows); wnck_pager_set_display_mode (WNCK_PAGER (pager->pager), pager->display_mode); wnck_pager_set_show_all (WNCK_PAGER (pager->pager), pager->display_all); }
static int pager_wnck_constructor(Plugin *plug, char **fp) { pager *pg; ENTER; pg = g_new0(pager, 1); g_return_val_if_fail(pg != NULL, 0); plug->priv = pg; pg->plugin = plug; plug->pwid = gtk_event_box_new(); GTK_WIDGET_SET_FLAGS( plug->pwid, GTK_NO_WINDOW ); pg->htable = g_hash_table_new (g_int_hash, g_int_equal); pg->box = wnck_pager_new(NULL); g_return_val_if_fail(pg->box != NULL, 0); //set orientation wnck_pager_set_orientation (WNCK_PAGER (pg->box),pg->plugin->panel->orientation); wnck_pager_set_n_rows (WNCK_PAGER (pg->box), 1); //pager->rows); wnck_pager_set_display_mode (WNCK_PAGER (pg->box),WNCK_PAGER_DISPLAY_CONTENT); //pager->show_names ? WNCK_PAGER_DISPLAY_NAME : WNCK_PAGER_DISPLAY_CONTENT); //gtk_widget_show (pg->box); //gtk_container_add (GTK_CONTAINER (plugin), pg->box); gtk_container_set_border_width (GTK_CONTAINER (pg->box), 2); gtk_widget_show(pg->box); gtk_container_set_border_width (GTK_CONTAINER (plug->pwid), 1); gtk_container_add(GTK_CONTAINER(plug->pwid), pg->box); pg->eb = pg->box; pg->ratio = (gfloat)gdk_screen_width() / (gfloat)gdk_screen_height(); pg->scaley = (gfloat)pg->dh / (gfloat)gdk_screen_height(); pg->scalex = (gfloat)pg->dw / (gfloat)gdk_screen_width(); pager_rebuild_all(fbev, pg); //do_net_current_desktop(fbev, pg); //do_net_client_list_stacking(fbev, pg); gdk_window_add_filter(NULL, (GdkFilterFunc)pager_event_filter, pg ); g_signal_connect (G_OBJECT (fbev), "current_desktop", G_CALLBACK (do_net_current_desktop), (gpointer) pg); g_signal_connect (G_OBJECT (fbev), "active_window", G_CALLBACK (do_net_active_window), (gpointer) pg); g_signal_connect (G_OBJECT (fbev), "number_of_desktops", G_CALLBACK (pager_rebuild_all), (gpointer) pg); g_signal_connect (G_OBJECT (fbev), "client_list_stacking", G_CALLBACK (do_net_client_list_stacking), (gpointer) pg); RET(1); }
static void applet_change_background (PanelApplet *applet, cairo_pattern_t *pattern, PagerData *pager) { wnck_pager_set_shadow_type (WNCK_PAGER (pager->pager), pattern != NULL ? GTK_SHADOW_NONE : GTK_SHADOW_IN); }
static void applet_realized (PanelApplet *applet, PagerData *pager) { WnckScreen *screen; screen = wncklet_get_screen (GTK_WIDGET (applet)); wnck_pager_set_screen (WNCK_PAGER (pager->pager), screen); }
static void wnck_workspace_accessible_get_extents (AtkComponent *component, int *x, int *y, int *width, int *height, AtkCoordType coords) { AtkGObjectAccessible *atk_gobj; WnckPager *pager; GdkRectangle rect; GtkWidget *widget; AtkObject *parent; GObject *g_obj; int px, py; g_return_if_fail (WNCK_IS_WORKSPACE_ACCESSIBLE (component)); atk_gobj = ATK_GOBJECT_ACCESSIBLE (component); g_obj = atk_gobject_accessible_get_object (atk_gobj); if (g_obj == NULL) return; g_return_if_fail (WNCK_IS_WORKSPACE (g_obj)); parent = atk_object_get_parent (ATK_OBJECT(component)); #if GTK_CHECK_VERSION(2,21,0) widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (parent)); #else widget = GTK_ACCESSIBLE (parent)->widget; #endif if (widget == NULL) { /* *State is defunct */ return; } g_return_if_fail (WNCK_IS_PAGER (widget)); pager = WNCK_PAGER (widget); g_return_if_fail (WNCK_IS_PAGER (pager)); atk_component_get_position (ATK_COMPONENT (parent), &px,&py, coords); _wnck_pager_get_workspace_rect (pager, WNCK_WORKSPACE_ACCESSIBLE (component)->index, &rect); *x = rect.x + px; *y = rect.y + py; *height = rect.height; *width = rect.width; }
static void applet_change_background (PanelApplet *applet, PanelAppletBackgroundType type, GdkColor *color, GdkPixmap *pixmap, PagerData *pager) { switch (type) { case PANEL_NO_BACKGROUND: wnck_pager_set_shadow_type (WNCK_PAGER (pager->pager), GTK_SHADOW_IN); break; case PANEL_COLOR_BACKGROUND: wnck_pager_set_shadow_type (WNCK_PAGER (pager->pager), GTK_SHADOW_NONE); break; case PANEL_PIXMAP_BACKGROUND: wnck_pager_set_shadow_type (WNCK_PAGER (pager->pager), GTK_SHADOW_NONE); break; } }
static void applet_change_background(MatePanelApplet* applet, MatePanelAppletBackgroundType type, GdkColor* color, cairo_pattern_t *pattern, PagerData* pager) { GtkStyleContext *new_context; gtk_widget_reset_style (GTK_WIDGET (pager->pager)); new_context = gtk_style_context_new (); gtk_style_context_set_path (new_context, gtk_widget_get_path (GTK_WIDGET (pager->pager))); g_object_unref (new_context); wnck_pager_set_shadow_type (WNCK_PAGER (pager->pager), type == PANEL_NO_BACKGROUND ? GTK_SHADOW_NONE : GTK_SHADOW_IN); #else static void applet_change_background(MatePanelApplet* applet, MatePanelAppletBackgroundType type, GdkColor* color, GdkPixmap* pixmap, PagerData* pager) { /* taken from the TrashApplet */ GtkRcStyle *rc_style; GtkStyle *style; /* reset style */ gtk_widget_set_style (GTK_WIDGET (pager->pager), NULL); rc_style = gtk_rc_style_new (); gtk_widget_modify_style (GTK_WIDGET (pager->pager), rc_style); g_object_unref (rc_style); switch (type) { case PANEL_COLOR_BACKGROUND: gtk_widget_modify_bg (GTK_WIDGET (pager->pager), GTK_STATE_NORMAL, color); break; case PANEL_PIXMAP_BACKGROUND: style = gtk_style_copy (gtk_widget_get_style (GTK_WIDGET (pager->pager))); if (style->bg_pixmap[GTK_STATE_NORMAL]) g_object_unref (style->bg_pixmap[GTK_STATE_NORMAL]); style->bg_pixmap[GTK_STATE_NORMAL] = g_object_ref(pixmap); gtk_widget_set_style (GTK_WIDGET (pager->pager), style); g_object_unref (style); break; case PANEL_NO_BACKGROUND: default: break; } #endif }
gboolean workspace_switcher_applet_fill (PanelApplet *applet) { PagerData *pager; GtkActionGroup *action_group; GtkAction *action; gboolean display_names; panel_applet_add_preferences (applet, "/schemas/apps/workspace_switcher_applet/prefs", NULL); pager = g_new0 (PagerData, 1); pager->applet = GTK_WIDGET (applet); panel_applet_set_flags (PANEL_APPLET (pager->applet), PANEL_APPLET_EXPAND_MINOR); setup_gconf (pager); pager->n_rows = g_settings_get_int (pager->settings, "num-rows"); display_names = g_settings_get_boolean (pager->settings, "display-workspace-names"); if (display_names) { pager->display_mode = WNCK_PAGER_DISPLAY_NAME; } else { pager->display_mode = WNCK_PAGER_DISPLAY_CONTENT; } pager->display_all = g_settings_get_boolean (pager->settings, "display-all-workspaces"); switch (panel_applet_get_orient (applet)) { case PANEL_APPLET_ORIENT_LEFT: case PANEL_APPLET_ORIENT_RIGHT: pager->orientation = GTK_ORIENTATION_VERTICAL; break; case PANEL_APPLET_ORIENT_UP: case PANEL_APPLET_ORIENT_DOWN: default: pager->orientation = GTK_ORIENTATION_HORIZONTAL; break; } pager->pager = wnck_pager_new (); pager->screen = NULL; pager->wm = PAGER_WM_UNKNOWN; wnck_pager_set_shadow_type (WNCK_PAGER (pager->pager), GTK_SHADOW_IN); g_signal_connect (G_OBJECT (pager->pager), "destroy", G_CALLBACK (destroy_pager), pager); gtk_container_add (GTK_CONTAINER (pager->applet), pager->pager); gtk_widget_show (pager->pager); g_signal_connect (G_OBJECT (pager->applet), "realize", G_CALLBACK (applet_realized), pager); g_signal_connect (G_OBJECT (pager->applet), "unrealize", G_CALLBACK (applet_unrealized), pager); g_signal_connect (G_OBJECT (pager->applet), "change_orient", G_CALLBACK (applet_change_orient), pager); g_signal_connect (G_OBJECT (pager->applet), "change_background", G_CALLBACK (applet_change_background), pager); gtk_widget_show (pager->applet); panel_applet_set_background_widget (PANEL_APPLET (pager->applet), GTK_WIDGET (pager->applet)); action_group = gtk_action_group_new ("WorkspaceSwitcher Applet Actions"); gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE); gtk_action_group_add_actions (action_group, pager_menu_actions, G_N_ELEMENTS (pager_menu_actions), pager); panel_applet_setup_menu_from_resource (PANEL_APPLET (pager->applet), WNCKLET_RESOURCE_PATH "workspace-switcher-menu.xml", action_group); action = gtk_action_group_get_action (action_group, "PagerPreferences"); g_object_bind_property (pager->applet, "locked-down", action, "visible", G_BINDING_DEFAULT|G_BINDING_INVERT_BOOLEAN|G_BINDING_SYNC_CREATE); g_object_unref (action_group); return TRUE; }
gboolean workspace_switcher_applet_fill (PanelApplet *applet) { PagerData *pager; GError *error; gboolean display_names; BonoboUIComponent* popup_component; panel_applet_add_preferences (applet, "/schemas/apps/workspace_switcher_applet/prefs", NULL); pager = g_new0 (PagerData, 1); pager->applet = GTK_WIDGET (applet); panel_applet_set_flags (PANEL_APPLET (pager->applet), PANEL_APPLET_EXPAND_MINOR); setup_gconf (pager); error = NULL; pager->n_rows = panel_applet_gconf_get_int (applet, "num_rows", &error); if (error) { g_printerr (_("Error loading num_rows value for Workspace Switcher: %s\n"), error->message); g_error_free (error); /* leave current value */ } pager->n_rows = CLAMP (pager->n_rows, 1, MAX_REASONABLE_ROWS); error = NULL; display_names = panel_applet_gconf_get_bool (applet, "display_workspace_names", &error); if (error) { g_printerr (_("Error loading display_workspace_names value for Workspace Switcher: %s\n"), error->message); g_error_free (error); /* leave current value */ } if (display_names) { pager->display_mode = WNCK_PAGER_DISPLAY_NAME; } else { pager->display_mode = WNCK_PAGER_DISPLAY_CONTENT; } error = NULL; pager->display_all = panel_applet_gconf_get_bool (applet, "display_all_workspaces", &error); if (error) { g_printerr (_("Error loading display_all_workspaces value for Workspace Switcher: %s\n"), error->message); g_error_free (error); /* leave current value */ } switch (panel_applet_get_orient (applet)) { case PANEL_APPLET_ORIENT_LEFT: case PANEL_APPLET_ORIENT_RIGHT: pager->orientation = GTK_ORIENTATION_VERTICAL; break; case PANEL_APPLET_ORIENT_UP: case PANEL_APPLET_ORIENT_DOWN: default: pager->orientation = GTK_ORIENTATION_HORIZONTAL; break; } pager->screen = wncklet_get_screen (pager->applet); /* because the pager doesn't respond to signals at the moment */ wnck_screen_force_update (pager->screen); pager->pager = wnck_pager_new (pager->screen); wnck_pager_set_shadow_type (WNCK_PAGER (pager->pager), GTK_SHADOW_IN); g_signal_connect (G_OBJECT (pager->pager), "destroy", G_CALLBACK (destroy_pager), pager); pager_update (pager); gtk_container_add (GTK_CONTAINER (pager->applet), pager->pager); gtk_widget_show (pager->pager); gtk_widget_show (pager->applet); g_signal_connect (G_OBJECT (pager->applet), "realize", G_CALLBACK (applet_realized), pager); g_signal_connect (G_OBJECT (pager->applet), "change_orient", G_CALLBACK (applet_change_orient), pager); g_signal_connect (G_OBJECT (pager->applet), "scroll-event", G_CALLBACK (applet_scroll), pager); g_signal_connect (G_OBJECT (pager->applet), "change_background", G_CALLBACK (applet_change_background), pager); panel_applet_set_background_widget (PANEL_APPLET (pager->applet), GTK_WIDGET (pager->applet)); panel_applet_setup_menu_from_file (PANEL_APPLET (pager->applet), NULL, "GNOME_WorkspaceSwitcherApplet.xml", NULL, pager_menu_verbs, pager); if (panel_applet_get_locked_down (PANEL_APPLET (pager->applet))) { BonoboUIComponent *popup_component; popup_component = panel_applet_get_popup_component (PANEL_APPLET (pager->applet)); bonobo_ui_component_set_prop (popup_component, "/commands/PagerPreferences", "hidden", "1", NULL); } popup_component = panel_applet_get_popup_component (PANEL_APPLET (pager->applet)); launchpad_integration_add_bonobo_ui(popup_component, "/popups/button3/LaunchpadItems"); return TRUE; }
gboolean workspace_switcher_applet_fill(MatePanelApplet* applet) { PagerData* pager; GtkActionGroup* action_group; gchar* ui_path; gboolean display_names; #if GTK_CHECK_VERSION (3, 0, 0) GtkCssProvider *provider; #endif pager = g_new0(PagerData, 1); pager->applet = GTK_WIDGET(applet); mate_panel_applet_set_flags(MATE_PANEL_APPLET(pager->applet), MATE_PANEL_APPLET_EXPAND_MINOR); setup_gsettings(pager); pager->n_rows = g_settings_get_int(pager->settings, "num-rows"); pager->n_rows = CLAMP(pager->n_rows, 1, MAX_REASONABLE_ROWS); display_names = g_settings_get_boolean(pager->settings, "display-workspace-names"); pager->wrap_workspaces = g_settings_get_boolean(pager->settings, "wrap-workspaces"); if (display_names) { pager->display_mode = WNCK_PAGER_DISPLAY_NAME; } else { pager->display_mode = WNCK_PAGER_DISPLAY_CONTENT; } pager->display_all = g_settings_get_boolean(pager->settings, "display-all-workspaces"); switch (mate_panel_applet_get_orient(applet)) { case MATE_PANEL_APPLET_ORIENT_LEFT: case MATE_PANEL_APPLET_ORIENT_RIGHT: pager->orientation = GTK_ORIENTATION_VERTICAL; break; case MATE_PANEL_APPLET_ORIENT_UP: case MATE_PANEL_APPLET_ORIENT_DOWN: default: pager->orientation = GTK_ORIENTATION_HORIZONTAL; break; } #ifdef WNCK_CHECK_VERSION #if WNCK_CHECK_VERSION (3, 0, 0) pager->pager = wnck_pager_new(); #else pager->pager = wnck_pager_new(NULL); #endif #else pager->pager = wnck_pager_new(NULL); #endif pager->screen = NULL; pager->wm = PAGER_WM_UNKNOWN; wnck_pager_set_shadow_type(WNCK_PAGER(pager->pager), GTK_SHADOW_IN); #if GTK_CHECK_VERSION (3, 0, 0) GtkStyleContext *context; context = gtk_widget_get_style_context (GTK_WIDGET (applet)); gtk_style_context_add_class (context, "wnck-applet"); context = gtk_widget_get_style_context (pager->pager); gtk_style_context_add_class (context, "wnck-pager"); provider = gtk_css_provider_new (); gtk_css_provider_load_from_data (provider, ".wnck-pager:selected {\n" "background-color: #4A90D9; }", -1, NULL); gtk_style_context_add_provider (context, GTK_STYLE_PROVIDER (provider), GTK_STYLE_PROVIDER_PRIORITY_FALLBACK); g_object_unref (provider); #endif g_signal_connect(G_OBJECT(pager->pager), "destroy", G_CALLBACK(destroy_pager), pager); gtk_container_add(GTK_CONTAINER(pager->applet), pager->pager); gtk_widget_show(pager->pager); g_signal_connect(G_OBJECT(pager->applet), "realize", G_CALLBACK(applet_realized), pager); g_signal_connect(G_OBJECT(pager->applet), "unrealize", G_CALLBACK(applet_unrealized), pager); g_signal_connect(G_OBJECT(pager->applet), "change_orient", G_CALLBACK(applet_change_orient), pager); #if !GTK_CHECK_VERSION (3, 0, 0) g_signal_connect(G_OBJECT(pager->applet), "scroll-event", G_CALLBACK(applet_scroll), pager); #endif g_signal_connect(G_OBJECT(pager->applet), "change_background", G_CALLBACK(applet_change_background), pager); gtk_widget_show(pager->applet); mate_panel_applet_set_background_widget(MATE_PANEL_APPLET(pager->applet), GTK_WIDGET(pager->applet)); action_group = gtk_action_group_new("WorkspaceSwitcher Applet Actions"); gtk_action_group_set_translation_domain(action_group, GETTEXT_PACKAGE); gtk_action_group_add_actions(action_group, pager_menu_actions, G_N_ELEMENTS(pager_menu_actions), pager); ui_path = g_build_filename(WNCK_MENU_UI_DIR, "workspace-switcher-menu.xml", NULL); mate_panel_applet_setup_menu_from_file(MATE_PANEL_APPLET(pager->applet), ui_path, action_group); g_free(ui_path); if (mate_panel_applet_get_locked_down(MATE_PANEL_APPLET(pager->applet))) { GtkAction *action; action = gtk_action_group_get_action(action_group, "PagerPreferences"); gtk_action_set_visible(action, FALSE); } g_object_unref(action_group); return TRUE; }