static void get_menu_pos (GtkMenu *menu, gint *x, gint *y, gboolean *push_in, gpointer data) { charpick_data *curr_data = data; GtkRequisition reqmenu; gint tempx, tempy, width, height; gint screen_width, screen_height; gtk_widget_get_preferred_size (GTK_WIDGET (menu), NULL, &reqmenu); gdk_window_get_origin (GDK_WINDOW (gtk_widget_get_window(curr_data->applet)), &tempx, &tempy); gdk_window_get_geometry (GDK_WINDOW (gtk_widget_get_window(curr_data->applet)), NULL, NULL, &width, &height ); switch (mate_panel_applet_get_orient (MATE_PANEL_APPLET (curr_data->applet))) { case MATE_PANEL_APPLET_ORIENT_DOWN: tempy += height; break; case MATE_PANEL_APPLET_ORIENT_UP: tempy -= reqmenu.height; break; case MATE_PANEL_APPLET_ORIENT_LEFT: tempx -= reqmenu.width; break; case MATE_PANEL_APPLET_ORIENT_RIGHT: tempx += width; break; } gdk_window_get_geometry (gdk_screen_get_root_window (gdk_screen_get_default()), NULL, NULL, &screen_width, &screen_height); *x = CLAMP (tempx, 0, MAX (0, screen_width - reqmenu.width)); *y = CLAMP (tempy, 0, MAX (0, screen_height - reqmenu.height)); }
static gboolean on_mouse_leave (GtkWidget *event_box, GdkEventButton *event, gpointer data) { int orientation; pqi const inst = (pqi)data; gtk_widget_queue_draw(event_box); inst->glowing = FALSE; /* No more glow */ /* Show the menu if it was gestured in the correct direction */ if (inst->clicked) { GtkAllocation alloc; int x = event->x, y = event->y; gtk_widget_get_allocation(inst->box, &alloc); /* Get the dimensions of our widget */ gtk_widget_get_pointer(inst->box, &x, &y); /* Get the location of our mouse */ /* Check if the mouse is dragging away from the panel */ orientation = mate_panel_applet_get_orient(inst->applet); if ((orientation == MATE_PANEL_APPLET_ORIENT_UP && x > -alloc.width /2 && x < 3*alloc.width /2 && y <= 0) || (orientation == MATE_PANEL_APPLET_ORIENT_RIGHT && y > -alloc.height/2 && y < 3*alloc.height/2 && x >= alloc.width) || (orientation == MATE_PANEL_APPLET_ORIENT_DOWN && x > -alloc.width /2 && x < 3*alloc.width /2 && y >= alloc.height) || (orientation == MATE_PANEL_APPLET_ORIENT_LEFT && y > -alloc.height/2 && y < 3*alloc.height/2 && x <= 0)) { /* Dragging out menu */ show_menu(inst); } else return TRUE; } return TRUE; }
/* This function shows a menu for the user to select which item to launch. */ void show_menu(pqi inst) { menu_iter iter; int i = 0, orient = mate_panel_applet_get_orient(inst->applet); GtkMenu* menu = GTK_MENU(gtk_menu_new()); gboolean reverse; if (inst->clicked && inst->items) { reverse = (orient == MATE_PANEL_APPLET_ORIENT_UP); for (reverse? menu_iterate_rbegin(inst,&iter,inst->show_primary):menu_iterate_begin(inst,&iter,inst->show_primary); iter.valid; menu_iter_next(&iter)) { GtkWidget *mi = gtk_image_menu_item_new(), *lbl = gtk_label_new(iter.text), *icon = gtk_image_new_from_gicon(iter.icon, GTK_ICON_SIZE_DND); gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(mi), icon); gtk_image_menu_item_set_always_show_image(GTK_IMAGE_MENU_ITEM(mi), TRUE); gtk_label_set_justify(GTK_LABEL(lbl),GTK_JUSTIFY_LEFT); gtk_misc_set_alignment(GTK_MISC(lbl),0,0.5); gtk_container_add(GTK_CONTAINER(mi),lbl); gtk_widget_show_all(mi); gtk_menu_insert(menu,mi,i++); g_signal_connect(G_OBJECT(mi), "activate", G_CALLBACK(menu_launch), iter.si); } gtk_menu_attach_to_widget(menu,inst->box,NULL); gtk_menu_popup(menu,NULL,NULL,set_to_corner, inst, 1, 0); } inst->clicked = FALSE; }
/** * gpm_applet_check_size: * @applet: Inhibit applet instance * * check if panel size has changed and applet adapt size **/ static void gpm_applet_check_size (GpmInhibitApplet *applet) { GtkAllocation allocation; /* we don't use the size function here, but the yet allocated size because the size value is false (kind of rounded) */ gtk_widget_get_allocation (GTK_WIDGET (applet), &allocation); if (MATE_PANEL_APPLET_VERTICAL(mate_panel_applet_get_orient (MATE_PANEL_APPLET (applet)))) { if (applet->size != allocation.width) { applet->size = allocation.width; gpm_applet_get_icon (applet); gtk_widget_set_size_request (GTK_WIDGET(applet), applet->size, applet->icon_height + 2); } /* Adjusting incase the icon size has changed */ if (allocation.height < applet->icon_height + 2) { gtk_widget_set_size_request (GTK_WIDGET(applet), applet->size, applet->icon_height + 2); } } else { if (applet->size != allocation.height) { applet->size = allocation.height; gpm_applet_get_icon (applet); gtk_widget_set_size_request (GTK_WIDGET(applet), applet->icon_width + 2, applet->size); } /* Adjusting incase the icon size has changed */ if (allocation.width < applet->icon_width + 2) { gtk_widget_set_size_request (GTK_WIDGET(applet), applet->icon_width + 2, applet->size); } } }
static void window_menu_size_allocate(MatePanelApplet* applet, GtkAllocation* allocation, WindowMenu* window_menu) { MatePanelAppletOrient orient; GList* children; GtkWidget* child; orient = mate_panel_applet_get_orient(applet); children = gtk_container_get_children(GTK_CONTAINER(window_menu->selector)); child = GTK_WIDGET(children->data); g_list_free(children); if (orient == MATE_PANEL_APPLET_ORIENT_LEFT || orient == MATE_PANEL_APPLET_ORIENT_RIGHT) { if (window_menu->size == allocation->width && orient == window_menu->orient) return; window_menu->size = allocation->width; gtk_widget_set_size_request(child, window_menu->size, -1); } else { if (window_menu->size == allocation->height && orient == window_menu->orient) return; window_menu->size = allocation->height; gtk_widget_set_size_request(child, -1, window_menu->size); } window_menu->orient = orient; }
ActiveSensor *active_sensor_new(SensorsApplet *sensors_applet, GtkTreeRowReference *sensor_row) { ActiveSensor *active_sensor; MatePanelAppletOrient orient; gint graph_size; gboolean horizontal; g_assert(sensors_applet); g_assert(sensor_row); g_debug("creating new active sensor"); active_sensor = g_new0(ActiveSensor, 1); active_sensor->sensors_applet = sensors_applet; active_sensor->sensor_row = sensor_row; int i; for (i = 0; i < NUM_NOTIFS; i++) { active_sensor->alarm_timeout_id[i] = -1; } active_sensor->label = gtk_label_new(""); active_sensor->value = gtk_label_new(""); active_sensor->icon = gtk_image_new(); active_sensor->graph = gtk_drawing_area_new(); active_sensor->graph_frame = gtk_frame_new(NULL); gtk_frame_set_shadow_type(GTK_FRAME(active_sensor->graph_frame), GTK_SHADOW_IN); gtk_container_add(GTK_CONTAINER(active_sensor->graph_frame), active_sensor->graph); gtk_widget_add_events(active_sensor->graph_frame, GDK_ALL_EVENTS_MASK); /* need to set size according to orientation */ orient = mate_panel_applet_get_orient(active_sensor->sensors_applet->applet); graph_size = g_settings_get_int(active_sensor->sensors_applet->settings, GRAPH_SIZE); horizontal = ((orient == MATE_PANEL_APPLET_ORIENT_UP) || (orient == MATE_PANEL_APPLET_ORIENT_DOWN)); active_sensor_set_graph_dimensions(active_sensor, (horizontal ? graph_size : sensors_applet->size), (horizontal ? sensors_applet->size : graph_size)); g_signal_connect(G_OBJECT(active_sensor->graph), #if GTK_CHECK_VERSION (3, 0, 0) "draw", G_CALLBACK(graph_draw_cb), #else "expose_event", G_CALLBACK(graph_expose_event_cb), #endif active_sensor); active_sensor->updated = FALSE; return active_sensor; }
static gboolean accessx_status_applet_reset(gpointer user_data) { AccessxStatusApplet* sapplet = user_data; g_assert(sapplet->applet); accessx_status_applet_reorient(GTK_WIDGET(sapplet->applet), mate_panel_applet_get_orient(sapplet->applet), sapplet); return FALSE; }
static void panel_resized(MatePanelApplet *applet, GtkAllocation *alloc, gpointer data) { pqi const inst = (pqi)data; int orientation = mate_panel_applet_get_orient(inst->applet); if (orientation == MATE_PANEL_APPLET_ORIENT_DOWN || orientation == MATE_PANEL_APPLET_ORIENT_UP) inst->size = alloc->height, gtk_widget_set_size_request(inst->box,inst->size,-1); if (orientation == MATE_PANEL_APPLET_ORIENT_LEFT || orientation == MATE_PANEL_APPLET_ORIENT_RIGHT ) inst->size = alloc->width, gtk_widget_set_size_request(inst->box,-1,inst->size); resolve_item_order(inst); }
static gboolean applet_factory (MatePanelApplet *applet, const char *iid, gpointer user_data) { gboolean ret = FALSE; GtkWidget *drive_list; AtkObject *ao; GtkActionGroup *action_group; gchar *ui_path; if (!strcmp (iid, drivemount_iid)) { g_set_application_name (_("Disk Mounter")); gtk_window_set_default_icon_name ("media-floppy"); mate_panel_applet_set_flags (applet, MATE_PANEL_APPLET_EXPAND_MINOR); mate_panel_applet_set_background_widget (applet, GTK_WIDGET (applet)); drive_list = drive_list_new (); gtk_container_add (GTK_CONTAINER (applet), drive_list); g_signal_connect_object (applet, "change_orient", G_CALLBACK (change_orient), drive_list, 0); g_signal_connect_object (applet, "size_allocate", G_CALLBACK (size_allocate), drive_list, 0); g_signal_connect (applet, "change_background", G_CALLBACK (change_background), drive_list); /* set initial state */ change_orient (applet, mate_panel_applet_get_orient (applet), DRIVE_LIST (drive_list)); action_group = gtk_action_group_new ("DriveMount Applet Actions"); gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE); gtk_action_group_add_actions (action_group, applet_menu_actions, G_N_ELEMENTS (applet_menu_actions), drive_list); ui_path = g_build_filename (DRIVEMOUNT_MENU_UI_DIR, "drivemount-applet-menu.xml", NULL); mate_panel_applet_setup_menu_from_file (applet, ui_path, action_group); g_free (ui_path); g_object_unref (action_group); ao = gtk_widget_get_accessible (GTK_WIDGET (applet)); atk_object_set_name (ao, _("Disk Mounter")); gtk_widget_show_all (GTK_WIDGET (applet)); ret = TRUE; } return ret; }
static void cpufreq_applet_popup_position_menu (GtkMenu *menu, int *x, int *y, gboolean *push_in, gpointer gdata) { GtkWidget *widget; GtkRequisition requisition; GtkAllocation allocation; gint menu_xpos; gint menu_ypos; widget = GTK_WIDGET (gdata); #if GTK_CHECK_VERSION (3, 0, 0) gtk_widget_get_preferred_size (GTK_WIDGET (menu), &requisition, NULL); #else gtk_widget_size_request (GTK_WIDGET (menu), &requisition); #endif gdk_window_get_origin (gtk_widget_get_window (widget), &menu_xpos, &menu_ypos); gtk_widget_get_allocation (widget, &allocation); menu_xpos += allocation.x; menu_ypos += allocation.y; switch (mate_panel_applet_get_orient (MATE_PANEL_APPLET (widget))) { case MATE_PANEL_APPLET_ORIENT_DOWN: case MATE_PANEL_APPLET_ORIENT_UP: if (menu_ypos > gdk_screen_get_height (gtk_widget_get_screen (widget)) / 2) menu_ypos -= requisition.height; else menu_ypos += allocation.height; break; case MATE_PANEL_APPLET_ORIENT_RIGHT: case MATE_PANEL_APPLET_ORIENT_LEFT: if (menu_xpos > gdk_screen_get_width (gtk_widget_get_screen (widget)) / 2) menu_xpos -= requisition.width; else menu_xpos += allocation.width; break; default: g_assert_not_reached (); } *x = menu_xpos; *y = menu_ypos; #if GTK_CHECK_VERSION (3, 0, 0) if (push_in) *push_in = FALSE; /*fix bottom panel menu rendering in gtk3*/ #else *push_in = TRUE; #endif }
/* remove the old graphs and rebuild them */ void multiload_applet_refresh(MultiloadApplet *ma) { gint i; MatePanelAppletOrient orientation; /* stop and free the old graphs */ for (i = 0; i < NGRAPHS; i++) { if (!ma->graphs[i]) continue; load_graph_stop(ma->graphs[i]); gtk_widget_destroy(ma->graphs[i]->main_widget); load_graph_unalloc(ma->graphs[i]); g_free(ma->graphs[i]); } if (ma->box) gtk_widget_destroy(ma->box); orientation = mate_panel_applet_get_orient(ma->applet); if ( (orientation == MATE_PANEL_APPLET_ORIENT_UP) || (orientation == MATE_PANEL_APPLET_ORIENT_DOWN) ) { ma->box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); } else ma->box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); gtk_container_add(GTK_CONTAINER(ma->applet), ma->box); /* create the NGRAPHS graphs, passing in their user-configurable properties with gsettings. */ multiload_create_graphs (ma); /* only start and display the graphs the user has turned on */ for (i = 0; i < NGRAPHS; i++) { gtk_box_pack_start(GTK_BOX(ma->box), ma->graphs[i]->main_widget, TRUE, TRUE, 1); if (ma->graphs[i]->visible) { gtk_widget_show_all (ma->graphs[i]->main_widget); load_graph_start(ma->graphs[i]); } } gtk_widget_show (ma->box); return; }
static gboolean applet_reconfigure (GtkDrawingArea *drawingArea, GdkEventConfigure *event, BubblemonApplet *bubble) { int width = event->width; int height = event->height; MatePanelAppletOrient orientation = mate_panel_applet_get_orient(MATE_PANEL_APPLET(bubble->applet)); if (orientation == MATE_PANEL_APPLET_ORIENT_LEFT || orientation == MATE_PANEL_APPLET_ORIENT_RIGHT) { // We're on a vertical panel, height is decided based on the width if (width <= RELATIVE_WIDTH) { height = RELATIVE_HEIGHT; } else { height = (width * RELATIVE_HEIGHT) / RELATIVE_WIDTH; } } else { // We're on a horizontal panel, width is decided based on the height if (height <= RELATIVE_HEIGHT) { width = RELATIVE_WIDTH; } else { width = (height * RELATIVE_WIDTH) / RELATIVE_HEIGHT; } } if (bubble->width == width && bubble->height == height) { // Already at the correct size, done! return TRUE; } gtk_widget_set_size_request(GTK_WIDGET(drawingArea), width, height); bubble->width = width; bubble->height = height; if (bubble->applet == NULL) { // Not yet all loaded up return TRUE; } bubble->rgb_buffer = g_realloc(bubble->rgb_buffer, width * height * 4);/* times 4 for A R G B */ bubblemon_setSize(bubble->bubblemon, width, height); ui_update(bubble); return TRUE; }
gboolean window_menu_applet_fill(MatePanelApplet* applet) { WindowMenu* window_menu; GtkActionGroup* action_group; gchar* ui_path; window_menu = g_new0(WindowMenu, 1); window_menu->applet = GTK_WIDGET(applet); #if GTK_CHECK_VERSION (3, 20, 0) gtk_widget_set_name (window_menu->applet, "window-menu-applet-button"); #else force_no_focus_padding(window_menu->applet); #endif gtk_widget_set_tooltip_text(window_menu->applet, _("Window Selector")); mate_panel_applet_set_flags(applet, MATE_PANEL_APPLET_EXPAND_MINOR); window_menu->size = mate_panel_applet_get_size(applet); window_menu->orient = mate_panel_applet_get_orient(applet); g_signal_connect(window_menu->applet, "destroy", G_CALLBACK(window_menu_destroy), window_menu); action_group = gtk_action_group_new("WindowMenu Applet Actions"); gtk_action_group_set_translation_domain(action_group, GETTEXT_PACKAGE); gtk_action_group_add_actions(action_group, window_menu_actions, G_N_ELEMENTS(window_menu_actions), window_menu); ui_path = g_build_filename(WNCK_MENU_UI_DIR, "window-menu-menu.xml", NULL); mate_panel_applet_setup_menu_from_file(applet, ui_path, action_group); g_free(ui_path); g_object_unref(action_group); window_menu->selector = wnck_selector_new(); gtk_container_add(GTK_CONTAINER(window_menu->applet), window_menu->selector); mate_panel_applet_set_background_widget(MATE_PANEL_APPLET(window_menu->applet), GTK_WIDGET(window_menu->selector)); g_signal_connect(window_menu->applet, "key_press_event", G_CALLBACK(window_menu_key_press_event), window_menu); g_signal_connect(window_menu->applet, "size-allocate", G_CALLBACK(window_menu_size_allocate), window_menu); g_signal_connect_after(G_OBJECT(window_menu->applet), "focus-in-event", G_CALLBACK(gtk_widget_queue_draw), window_menu); g_signal_connect_after(G_OBJECT(window_menu->applet), "focus-out-event", G_CALLBACK(gtk_widget_queue_draw), window_menu); g_signal_connect_after(G_OBJECT(window_menu->selector), "draw", G_CALLBACK(window_menu_on_draw), window_menu); g_signal_connect(G_OBJECT(window_menu->selector), "button_press_event", G_CALLBACK(filter_button_press), window_menu); gtk_widget_show_all(GTK_WIDGET(window_menu->applet)); return TRUE; }
static void cpufreq_applet_popup_position_menu (GtkMenu *menu, int *x, int *y, gboolean *push_in, gpointer gdata) { GtkWidget *widget; GtkRequisition requisition; GtkAllocation allocation; gint menu_xpos; gint menu_ypos; widget = GTK_WIDGET (gdata); gtk_widget_size_request (GTK_WIDGET (menu), &requisition); gdk_window_get_origin (gtk_widget_get_window (widget), &menu_xpos, &menu_ypos); gtk_widget_get_allocation (widget, &allocation); menu_xpos += allocation.x; menu_ypos += allocation.y; switch (mate_panel_applet_get_orient (MATE_PANEL_APPLET (widget))) { case MATE_PANEL_APPLET_ORIENT_DOWN: case MATE_PANEL_APPLET_ORIENT_UP: if (menu_ypos > gdk_screen_get_height (gtk_widget_get_screen (widget)) / 2) menu_ypos -= requisition.height; else menu_ypos += allocation.height; break; case MATE_PANEL_APPLET_ORIENT_RIGHT: case MATE_PANEL_APPLET_ORIENT_LEFT: if (menu_xpos > gdk_screen_get_width (gtk_widget_get_screen (widget)) / 2) menu_xpos -= requisition.width; else menu_xpos += allocation.width; break; default: g_assert_not_reached (); } *x = menu_xpos; *y = menu_ypos; *push_in = TRUE; }
void set_to_corner(GtkMenu* menu, gint *x, gint *y, gboolean *set_to_false, gpointer data) { pqi const inst = (pqi)data; /* Wrap for beauty */ /* Get some information about our widget */ struct xy mxy; GdkWindow *window; GdkRectangle monitor; GtkAllocation alloc; GtkRequisition smenu; *set_to_false = FALSE; /* Don't touch my menu. */ window = gtk_widget_get_parent_window(inst->box); /* getting parent window */ gdk_window_get_origin(window, &mxy.x1, &mxy.y1); /* parent's left-top screen coordinates */ gdk_screen_get_monitor_geometry(gtk_widget_get_screen(inst->box), gtk_menu_get_monitor(menu), &monitor); /* Get the coordinates of the rectangle this screen displays */ mxy.x2 = mxy.x1, mxy.y2 = mxy.y1; gtk_widget_get_allocation(inst->box, &alloc); /* Get the dimensions of our widget */ switch (mate_panel_applet_get_orient(inst->applet)) /* Which points we use depends on the orientation of our panel */ { case MATE_PANEL_APPLET_ORIENT_UP: mxy.x2 += alloc.width; break; case MATE_PANEL_APPLET_ORIENT_RIGHT: mxy.x1 += alloc.width; mxy.x2 += alloc.width; mxy.y2 += alloc.height; break; case MATE_PANEL_APPLET_ORIENT_DOWN: mxy.y1 += alloc.height; mxy.y2 += alloc.height; mxy.x2 += alloc.width; break; case MATE_PANEL_APPLET_ORIENT_LEFT: mxy.y2 += alloc.height; break; } mxy.x1 += monitor.x, mxy.x2 += monitor.x, mxy.y1 += monitor.y, mxy.y2 += monitor.y; /* Account for x and y offsets if this screen isn't at the top-left corner */ gtk_widget_size_request(GTK_WIDGET(menu), &smenu); /* Get the dimensions of our menu */ if (mxy.x1 + smenu.width > monitor.x + monitor.width) { if (mxy.x2 - smenu.width > monitor.x) mxy.x1 = mxy.x2 - smenu.width; else mxy.x1 = monitor.x + monitor.width - smenu.width; } if (mxy.y1 + smenu.height > monitor.y + monitor.height) { if (mxy.y2 - smenu.height > monitor.y) mxy.y1 = mxy.y2 - smenu.height; else mxy.y1 = monitor.y + monitor.height - smenu.height; } *x = mxy.x1, *y = mxy.y1; /* Just use the position we logged earlier */ }
static GtkOrientation get_orientation_from_applet(MatePanelApplet* applet) { GtkOrientation orientation; switch (mate_panel_applet_get_orient(applet)) { case MATE_PANEL_APPLET_ORIENT_LEFT: case MATE_PANEL_APPLET_ORIENT_RIGHT: orientation = GTK_ORIENTATION_VERTICAL; break; case MATE_PANEL_APPLET_ORIENT_UP: case MATE_PANEL_APPLET_ORIENT_DOWN: default: orientation = GTK_ORIENTATION_HORIZONTAL; break; } return orientation; }
static void size_allocate (MatePanelApplet *applet, GdkRectangle *allocation, DriveList *drive_list) { int size; switch (mate_panel_applet_get_orient (applet)) { case MATE_PANEL_APPLET_ORIENT_LEFT: case MATE_PANEL_APPLET_ORIENT_RIGHT: size = allocation->width; break; case MATE_PANEL_APPLET_ORIENT_UP: case MATE_PANEL_APPLET_ORIENT_DOWN: default: size = allocation->height; break; } drive_list_set_panel_size (drive_list, size); }
static void cpufreq_applet_init (CPUFreqApplet *applet) { applet->prefs = NULL; applet->popup = NULL; applet->monitor = NULL; applet->label = gtk_label_new (NULL); applet->unit_label = gtk_label_new (NULL); applet->icon = gtk_image_new (); applet->box = NULL; applet->show_mode = CPUFREQ_MODE_BOTH; applet->show_text_mode = CPUFREQ_MODE_TEXT_FREQUENCY_UNIT; applet->need_refresh = TRUE; mate_panel_applet_set_flags (MATE_PANEL_APPLET (applet), MATE_PANEL_APPLET_EXPAND_MINOR); #if !GTK_CHECK_VERSION (3, 0, 0) mate_panel_applet_set_background_widget (MATE_PANEL_APPLET (applet), GTK_WIDGET (applet)); #endif applet->size = mate_panel_applet_get_size (MATE_PANEL_APPLET (applet)); applet->orient = mate_panel_applet_get_orient (MATE_PANEL_APPLET (applet)); switch (applet->orient) { case MATE_PANEL_APPLET_ORIENT_LEFT: case MATE_PANEL_APPLET_ORIENT_RIGHT: applet->container = gtk_alignment_new (0.5, 0.5, 0, 0); break; case MATE_PANEL_APPLET_ORIENT_UP: case MATE_PANEL_APPLET_ORIENT_DOWN: applet->container = gtk_alignment_new (0, 0.5, 0, 0); break; } gtk_container_add (GTK_CONTAINER (applet), applet->container); gtk_widget_show (applet->container); }
static void trash_applet_size_allocate (GtkWidget *widget, GdkRectangle *allocation) { TrashApplet *applet = TRASH_APPLET (widget); switch (mate_panel_applet_get_orient (MATE_PANEL_APPLET (applet))) { case MATE_PANEL_APPLET_ORIENT_LEFT: case MATE_PANEL_APPLET_ORIENT_RIGHT: trash_applet_set_icon_size (applet, allocation->width); break; case MATE_PANEL_APPLET_ORIENT_UP: case MATE_PANEL_APPLET_ORIENT_DOWN: trash_applet_set_icon_size (applet, allocation->height); break; } GTK_WIDGET_CLASS (trash_applet_parent_class) ->size_allocate (widget, allocation); }
int mc_show_history (GtkWidget *widget, MCData *mc) { GtkWidget *window; GtkWidget *frame; GtkWidget *scrolled_window; GtkListStore *store; GtkTreeIter iter; GtkTreeModel *model; GtkWidget *treeview; GtkCellRenderer *cell_renderer; GtkTreeViewColumn *column; GtkRequisition req; gchar *command_list[1]; int i, j; gint x, y, width, height, screen_width, screen_height; /* count commands stored in history list */ for(i = 0, j = 0; i < MC_HISTORY_LIST_LENGTH; i++) if(exists_history_entry(i)) j++; window = gtk_window_new(GTK_WINDOW_POPUP); gtk_window_set_screen (GTK_WINDOW (window), gtk_widget_get_screen (GTK_WIDGET (mc->applet))); gtk_window_set_resizable(GTK_WINDOW(window), FALSE); gtk_window_set_type_hint(GTK_WINDOW(window), GDK_WINDOW_TYPE_HINT_COMBO); /* cb */ g_signal_connect_after(GTK_OBJECT(window), "button_press_event", G_CALLBACK(history_popup_clicked_cb), NULL); g_signal_connect_after (G_OBJECT (window), "key_press_event", G_CALLBACK (history_key_press_cb), NULL); /* size */ gtk_widget_set_size_request(GTK_WIDGET(window), 200, 350); /* frame */ frame = gtk_frame_new(NULL); gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_OUT); gtk_widget_show(frame); gtk_container_add(GTK_CONTAINER(window), frame); /* scrollbars */ /* create scrolled window to put the Gtk_list widget inside */ scrolled_window=gtk_scrolled_window_new(NULL, NULL); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); g_signal_connect(GTK_OBJECT(scrolled_window), "button_press_event", G_CALLBACK(history_popup_clicked_inside_cb), NULL); gtk_container_add(GTK_CONTAINER(frame), scrolled_window); gtk_container_set_border_width (GTK_CONTAINER(scrolled_window), 2); gtk_widget_show(scrolled_window); store = gtk_list_store_new (1, G_TYPE_STRING); /* add history entries to list */ if (j == 0) { gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter,0, _("No items in history"), -1); } else { for(i = 0; i < MC_HISTORY_LIST_LENGTH; i++) { if(exists_history_entry(i)) { command_list[0] = get_history_entry(i); gtk_list_store_prepend (store, &iter); gtk_list_store_set (store, &iter,0,command_list[0],-1); } } } model = GTK_TREE_MODEL(store); treeview = gtk_tree_view_new_with_model (model); g_object_set_data (G_OBJECT (mc->applet), "tree", treeview); cell_renderer = gtk_cell_renderer_text_new (); column = gtk_tree_view_column_new_with_attributes (NULL, cell_renderer, "text", 0, NULL); gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column); gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (treeview), FALSE); if (j == 0) { gtk_tree_selection_set_mode( (GtkTreeSelection *)gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview)), GTK_SELECTION_NONE); } else { gtk_tree_selection_set_mode( (GtkTreeSelection *)gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview)), GTK_SELECTION_SINGLE); g_signal_connect (G_OBJECT (treeview), "button_press_event", G_CALLBACK (history_list_button_press_cb), mc); g_signal_connect (G_OBJECT (treeview), "key_press_event", G_CALLBACK (history_list_key_press_cb), mc); } g_object_unref (G_OBJECT (model)); gtk_container_add(GTK_CONTAINER(scrolled_window),treeview); gtk_widget_show (treeview); gtk_widget_size_request (window, &req); gdk_window_get_origin (GTK_WIDGET (mc->applet)->window, &x, &y); gdk_window_get_geometry (GTK_WIDGET (mc->applet)->window, NULL, NULL, &width, &height, NULL); switch (mate_panel_applet_get_orient (mc->applet)) { case MATE_PANEL_APPLET_ORIENT_DOWN: y += height; break; case MATE_PANEL_APPLET_ORIENT_UP: y -= req.height; break; case MATE_PANEL_APPLET_ORIENT_LEFT: x -= req.width; break; case MATE_PANEL_APPLET_ORIENT_RIGHT: x += width; break; } screen_width = gdk_screen_width (); screen_height = gdk_screen_height (); x = CLAMP (x - 2, 0, MAX (0, screen_width - req.width)); y = CLAMP (y - 2, 0, MAX (0, screen_height - req.height)); gtk_window_move (GTK_WINDOW (window), x, y); gtk_widget_show(window); /* grab focus */ gdk_pointer_grab (window->window, TRUE, GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK | GDK_POINTER_MOTION_MASK, NULL, NULL, GDK_CURRENT_TIME); gdk_keyboard_grab (window->window, TRUE, GDK_CURRENT_TIME); gtk_grab_add(window); gtk_widget_grab_focus (treeview); return FALSE; }
static AccessxStatusApplet* create_applet(MatePanelApplet* applet) { AccessxStatusApplet* sapplet = g_new0(AccessxStatusApplet, 1); GtkWidget* box; GtkWidget* stickyfoo; AtkObject* atko; GdkPixbuf* pixbuf; gint large_toolbar_pixels; g_set_application_name(_("AccessX Status")); sapplet->xkb = NULL; sapplet->xkb_display = NULL; sapplet->box = NULL; sapplet->initialized = False; /* there must be a better way */ sapplet->error_type = ACCESSX_STATUS_ERROR_NONE; sapplet->applet = applet; mate_panel_applet_set_flags(applet, MATE_PANEL_APPLET_EXPAND_MINOR); sapplet->orient = mate_panel_applet_get_orient(applet); if (sapplet->orient == MATE_PANEL_APPLET_ORIENT_LEFT || sapplet->orient == MATE_PANEL_APPLET_ORIENT_RIGHT) { box = gtk_vbox_new(FALSE, 0); stickyfoo = gtk_vbox_new(TRUE, 0); } else { box = gtk_hbox_new(FALSE, 0); stickyfoo = gtk_hbox_new(TRUE, 0); } #if GTK_CHECK_VERSION (3, 0, 0) gtk_box_set_homogeneous (GTK_BOX (stickyfoo), TRUE); #endif large_toolbar_pixels = 24; /* FIXME */ if (mate_panel_applet_get_size(sapplet->applet) >= large_toolbar_pixels) { icon_size_spec = GTK_ICON_SIZE_LARGE_TOOLBAR; } else { icon_size_spec = GTK_ICON_SIZE_SMALL_TOOLBAR; } accessx_applet_add_stock_icons(sapplet, box); pixbuf = accessx_status_applet_mousekeys_image(sapplet, NULL); sapplet->mousefoo = gtk_image_new_from_pixbuf(pixbuf); g_object_unref(pixbuf); gtk_widget_hide(sapplet->mousefoo); sapplet->shift_indicator = gtk_image_new_from_stock(SHIFT_KEY_ICON, icon_size_spec); gtk_widget_hide(sapplet->mousefoo); sapplet->ctrl_indicator = gtk_image_new_from_stock(CONTROL_KEY_ICON, icon_size_spec); sapplet->alt_indicator = gtk_image_new_from_stock(ALT_KEY_ICON, icon_size_spec); sapplet->meta_indicator = gtk_image_new_from_stock(META_KEY_ICON, icon_size_spec); gtk_widget_set_sensitive(sapplet->meta_indicator, FALSE); gtk_widget_hide(sapplet->meta_indicator); sapplet->hyper_indicator = gtk_image_new_from_stock(HYPER_KEY_ICON, icon_size_spec); gtk_widget_set_sensitive(sapplet->hyper_indicator, FALSE); gtk_widget_hide(sapplet->hyper_indicator); sapplet->super_indicator = gtk_image_new_from_stock(SUPER_KEY_ICON, icon_size_spec); gtk_widget_set_sensitive(sapplet->super_indicator, FALSE); gtk_widget_hide(sapplet->super_indicator); sapplet->alt_graph_indicator = gtk_image_new_from_stock(ALTGRAPH_KEY_ICON, icon_size_spec); gtk_widget_set_sensitive(sapplet->alt_graph_indicator, FALSE); pixbuf = accessx_status_applet_slowkeys_image(sapplet, NULL); sapplet->slowfoo = gtk_image_new_from_pixbuf(pixbuf); g_object_unref(pixbuf); gtk_widget_hide(sapplet->slowfoo); pixbuf = accessx_status_applet_bouncekeys_image(sapplet, NULL); sapplet->bouncefoo = gtk_image_new_from_pixbuf(pixbuf); g_object_unref(pixbuf); gtk_widget_hide(sapplet->bouncefoo); sapplet->idlefoo = gtk_image_new_from_stock(ACCESSX_APPLET, icon_size_spec); gtk_widget_show(sapplet->slowfoo); accessx_status_applet_layout_box(sapplet, box, stickyfoo); atko = gtk_widget_get_accessible(GTK_WIDGET(sapplet->applet)); atk_object_set_name(atko, _("AccessX Status")); atk_object_set_description(atko, _("Shows keyboard status when accessibility features are used.")); return sapplet; }
gboolean show_desktop_applet_fill(MatePanelApplet* applet) { ShowDesktopData* sdd; GtkActionGroup* action_group; AtkObject* atk_obj; GtkCssProvider *provider; mate_panel_applet_set_flags(applet, MATE_PANEL_APPLET_EXPAND_MINOR); sdd = g_new0(ShowDesktopData, 1); sdd->applet = GTK_WIDGET(applet); sdd->image = gtk_image_new(); switch (mate_panel_applet_get_orient(applet)) { case MATE_PANEL_APPLET_ORIENT_LEFT: case MATE_PANEL_APPLET_ORIENT_RIGHT: sdd->orient = GTK_ORIENTATION_VERTICAL; break; case MATE_PANEL_APPLET_ORIENT_UP: case MATE_PANEL_APPLET_ORIENT_DOWN: default: sdd->orient = GTK_ORIENTATION_HORIZONTAL; break; } sdd->size = mate_panel_applet_get_size(MATE_PANEL_APPLET(sdd->applet)); g_signal_connect(G_OBJECT(sdd->applet), "realize", G_CALLBACK(show_desktop_applet_realized), sdd); sdd->button = gtk_toggle_button_new (); gtk_widget_set_name (sdd->button, "showdesktop-button"); provider = gtk_css_provider_new (); gtk_css_provider_load_from_data (provider, "#showdesktop-button {\n" "border-width: 0px; \n" /*a border here causes GTK warnings */ " padding: 0px;\n" " margin: 0px; }", -1, NULL); gtk_style_context_add_provider (gtk_widget_get_style_context (sdd->button), GTK_STYLE_PROVIDER (provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); g_object_unref (provider); atk_obj = gtk_widget_get_accessible(sdd->button); atk_object_set_name (atk_obj, _("Show Desktop Button")); g_signal_connect(G_OBJECT(sdd->button), "button_press_event", G_CALLBACK(do_not_eat_button_press), NULL); g_signal_connect(G_OBJECT(sdd->button), "toggled", G_CALLBACK(button_toggled_callback), sdd); gtk_container_set_border_width(GTK_CONTAINER(sdd->button), 0); gtk_container_add(GTK_CONTAINER(sdd->button), sdd->image); gtk_container_add(GTK_CONTAINER(sdd->applet), sdd->button); g_signal_connect (G_OBJECT(sdd->button), "size_allocate", G_CALLBACK(button_size_allocated), sdd); /* FIXME: Update this comment. */ /* we have to bind change_orient before we do applet_widget_add since we need to get an initial change_orient signal to set our initial oriantation, and we get that during the _add call */ g_signal_connect(G_OBJECT (sdd->applet), "change_orient", G_CALLBACK (applet_change_orient), sdd); mate_panel_applet_set_background_widget(MATE_PANEL_APPLET (sdd->applet), GTK_WIDGET(sdd->applet)); action_group = gtk_action_group_new("ShowDesktop Applet Actions"); gtk_action_group_set_translation_domain(action_group, GETTEXT_PACKAGE); gtk_action_group_add_actions(action_group, show_desktop_menu_actions, G_N_ELEMENTS (show_desktop_menu_actions), sdd); mate_panel_applet_setup_menu_from_resource (MATE_PANEL_APPLET (sdd->applet), WNCKLET_RESOURCE_PATH "showdesktop-menu.xml", action_group); g_object_unref(action_group); g_signal_connect(G_OBJECT(sdd->applet), "destroy", G_CALLBACK(applet_destroyed), sdd); gtk_drag_dest_set(GTK_WIDGET(sdd->button), 0, NULL, 0, 0); g_signal_connect(G_OBJECT(sdd->button), "drag_motion", G_CALLBACK (button_drag_motion), sdd); g_signal_connect(G_OBJECT(sdd->button), "drag_leave", G_CALLBACK (button_drag_leave), sdd); gtk_widget_show_all(sdd->applet); return TRUE; }
gboolean workspace_switcher_applet_fill(MatePanelApplet* applet) { PagerData* pager; GtkActionGroup* action_group; gchar* ui_path; GError* error; gboolean display_names; mate_panel_applet_add_preferences(applet, "/schemas/apps/workspace_switcher_applet/prefs", NULL); 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_mateconf(pager); error = NULL; pager->n_rows = mate_panel_applet_mateconf_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 = mate_panel_applet_mateconf_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 = MATEWNCK_PAGER_DISPLAY_NAME; } else { pager->display_mode = MATEWNCK_PAGER_DISPLAY_CONTENT; } error = NULL; pager->display_all = mate_panel_applet_mateconf_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 (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; } pager->pager = matewnck_pager_new(NULL); pager->screen = NULL; pager->wm = PAGER_WM_UNKNOWN; matewnck_pager_set_shadow_type(MATEWNCK_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), "scroll-event", G_CALLBACK(applet_scroll), pager); 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; }
gboolean window_list_applet_fill(MatePanelApplet* applet) { TasklistData* tasklist; GtkActionGroup* action_group; gchar* ui_path; tasklist = g_new0(TasklistData, 1); tasklist->applet = GTK_WIDGET(applet); mate_panel_applet_set_flags(MATE_PANEL_APPLET(tasklist->applet), MATE_PANEL_APPLET_EXPAND_MAJOR | MATE_PANEL_APPLET_EXPAND_MINOR | MATE_PANEL_APPLET_HAS_HANDLE); setup_gsettings(tasklist); tasklist->include_all_workspaces = g_settings_get_boolean (tasklist->settings, "display-all-workspaces"); tasklist->grouping = g_settings_get_enum (tasklist->settings, "group-windows"); tasklist->move_unminimized_windows = g_settings_get_boolean (tasklist->settings, "move-unminimized-windows"); tasklist->size = mate_panel_applet_get_size(applet); switch (mate_panel_applet_get_orient(applet)) { case MATE_PANEL_APPLET_ORIENT_LEFT: case MATE_PANEL_APPLET_ORIENT_RIGHT: tasklist->orientation = GTK_ORIENTATION_VERTICAL; break; case MATE_PANEL_APPLET_ORIENT_UP: case MATE_PANEL_APPLET_ORIENT_DOWN: default: tasklist->orientation = GTK_ORIENTATION_HORIZONTAL; break; } #ifdef WNCK_CHECK_VERSION #if WNCK_CHECK_VERSION (3, 0, 0) tasklist->tasklist = wnck_tasklist_new(); #else tasklist->tasklist = wnck_tasklist_new(NULL); #endif #else tasklist->tasklist = wnck_tasklist_new(NULL); #endif #ifdef WNCK_CHECK_VERSION #if WNCK_CHECK_VERSION (3, 4, 6) wnck_tasklist_set_orientation (WNCK_TASKLIST (tasklist->tasklist), tasklist->orientation); wnck_tasklist_set_middle_click_close (WNCK_TASKLIST (tasklist->tasklist), TRUE); #endif #endif wnck_tasklist_set_icon_loader(WNCK_TASKLIST(tasklist->tasklist), icon_loader_func, tasklist, NULL); g_signal_connect(G_OBJECT(tasklist->tasklist), "destroy", G_CALLBACK(destroy_tasklist), tasklist); #if GTK_CHECK_VERSION (3, 0, 0) g_signal_connect(G_OBJECT(tasklist->applet), "size_allocate", G_CALLBACK(applet_size_allocate), tasklist); #else g_signal_connect(G_OBJECT(tasklist->applet), "size_request", G_CALLBACK(applet_size_request), tasklist); #endif tasklist_update(tasklist); gtk_widget_show(tasklist->tasklist); gtk_container_add(GTK_CONTAINER(tasklist->applet), tasklist->tasklist); g_signal_connect(G_OBJECT(tasklist->applet), "realize", G_CALLBACK(applet_realized), tasklist); g_signal_connect(G_OBJECT(tasklist->applet), "change_orient", G_CALLBACK(applet_change_orient), tasklist); g_signal_connect(G_OBJECT(tasklist->applet), "change_size", G_CALLBACK(applet_change_pixel_size), tasklist); g_signal_connect(G_OBJECT(tasklist->applet), "change_background", G_CALLBACK(applet_change_background), tasklist); mate_panel_applet_set_background_widget(MATE_PANEL_APPLET(tasklist->applet), GTK_WIDGET(tasklist->applet)); action_group = gtk_action_group_new("Tasklist Applet Actions"); gtk_action_group_set_translation_domain(action_group, GETTEXT_PACKAGE); gtk_action_group_add_actions(action_group, tasklist_menu_actions, G_N_ELEMENTS(tasklist_menu_actions), tasklist); /* disable the item of system monitor, if not exists. * example, mate-system-monitor, o gnome-system-monitor */ char* programpath; int i; for (i = 0; i < G_N_ELEMENTS(system_monitors); i += 1) { programpath = g_find_program_in_path(system_monitors[i]); if (programpath != NULL) { g_free(programpath); /* we give up */ goto _system_monitor_found; } /* search another */ } /* system monitor not found */ gtk_action_set_visible(gtk_action_group_get_action(action_group, "TasklistSystemMonitor"), FALSE); _system_monitor_found:; /* end of system monitor item */ ui_path = g_build_filename(WNCK_MENU_UI_DIR, "window-list-menu.xml", NULL); mate_panel_applet_setup_menu_from_file(MATE_PANEL_APPLET(tasklist->applet), ui_path, action_group); g_free(ui_path); if (mate_panel_applet_get_locked_down(MATE_PANEL_APPLET(tasklist->applet))) { GtkAction* action; action = gtk_action_group_get_action(action_group, "TasklistPreferences"); gtk_action_set_visible(action, FALSE); } g_object_unref(action_group); gtk_widget_show(tasklist->applet); return TRUE; }
void mateweather_applet_create (MateWeatherApplet *gw_applet) { GtkActionGroup *action_group; gchar *ui_path; AtkObject *atk_obj; gw_applet->mateweather_pref.location = NULL; gw_applet->mateweather_pref.show_notifications = FALSE; gw_applet->mateweather_pref.update_interval = 1800; gw_applet->mateweather_pref.update_enabled = TRUE; gw_applet->mateweather_pref.detailed = FALSE; gw_applet->mateweather_pref.radar_enabled = TRUE; gw_applet->mateweather_pref.temperature_unit = TEMP_UNIT_INVALID; gw_applet->mateweather_pref.speed_unit = SPEED_UNIT_INVALID; gw_applet->mateweather_pref.pressure_unit = PRESSURE_UNIT_INVALID; gw_applet->mateweather_pref.distance_unit = DISTANCE_UNIT_INVALID; mate_panel_applet_set_flags (gw_applet->applet, MATE_PANEL_APPLET_EXPAND_MINOR); mate_panel_applet_set_background_widget(gw_applet->applet, GTK_WIDGET(gw_applet->applet)); g_set_application_name (_("Weather Report")); gtk_window_set_default_icon_name ("weather-storm"); gw_applet->container = gtk_alignment_new (0.5, 0.5, 0, 0); gtk_container_add (GTK_CONTAINER (gw_applet->applet), gw_applet->container); g_signal_connect (G_OBJECT(gw_applet->applet), "change_orient", G_CALLBACK(change_orient_cb), gw_applet); g_signal_connect (G_OBJECT(gw_applet->applet), "size_allocate", G_CALLBACK(size_allocate_cb), gw_applet); g_signal_connect (G_OBJECT(gw_applet->applet), "destroy", G_CALLBACK (applet_destroy), gw_applet); g_signal_connect (GTK_OBJECT(gw_applet->applet), "button_press_event", G_CALLBACK(clicked_cb), gw_applet); g_signal_connect (G_OBJECT(gw_applet->applet), "key_press_event", G_CALLBACK(key_press_cb), gw_applet); gtk_widget_set_tooltip_text (GTK_WIDGET(gw_applet->applet), _("MATE Weather")); atk_obj = gtk_widget_get_accessible (GTK_WIDGET (gw_applet->applet)); if (GTK_IS_ACCESSIBLE (atk_obj)) atk_object_set_name (atk_obj, _("MATE Weather")); gw_applet->size = mate_panel_applet_get_size (gw_applet->applet); gw_applet->orient = mate_panel_applet_get_orient (gw_applet->applet); action_group = gtk_action_group_new ("MateWeather Applet Actions"); gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE); gtk_action_group_add_actions (action_group, weather_applet_menu_actions, G_N_ELEMENTS (weather_applet_menu_actions), gw_applet); ui_path = g_build_filename (MATEWEATHER_MENU_UI_DIR, "mateweather-applet-menu.xml", NULL); mate_panel_applet_setup_menu_from_file (gw_applet->applet, ui_path, action_group); g_free (ui_path); if (mate_panel_applet_get_locked_down (gw_applet->applet)) { GtkAction *action; action = gtk_action_group_get_action (action_group, "Props"); gtk_action_set_visible (action, FALSE); } g_object_unref (action_group); place_widgets(gw_applet); #ifdef HAVE_NETWORKMANAGER setup_network_monitor (gw_applet); #endif }
gboolean show_desktop_applet_fill(MatePanelApplet* applet) { ShowDesktopData* sdd; GtkActionGroup* action_group; gchar* ui_path; AtkObject* atk_obj; mate_panel_applet_set_flags(applet, MATE_PANEL_APPLET_EXPAND_MINOR); sdd = g_new0(ShowDesktopData, 1); sdd->applet = GTK_WIDGET(applet); sdd->image = gtk_image_new(); switch (mate_panel_applet_get_orient(applet)) { case MATE_PANEL_APPLET_ORIENT_LEFT: case MATE_PANEL_APPLET_ORIENT_RIGHT: sdd->orient = GTK_ORIENTATION_VERTICAL; break; case MATE_PANEL_APPLET_ORIENT_UP: case MATE_PANEL_APPLET_ORIENT_DOWN: default: sdd->orient = GTK_ORIENTATION_HORIZONTAL; break; } sdd->size = mate_panel_applet_get_size(MATE_PANEL_APPLET(sdd->applet)); g_signal_connect(G_OBJECT(sdd->applet), "realize", G_CALLBACK(show_desktop_applet_realized), sdd); sdd->button = gtk_toggle_button_new (); gtk_widget_set_name (sdd->button, "showdesktop-button"); gtk_rc_parse_string ("\n" " style \"showdesktop-button-style\"\n" " {\n" " GtkWidget::focus-line-width=0\n" " GtkWidget::focus-padding=0\n" " }\n" "\n" " widget \"*.showdesktop-button\" style \"showdesktop-button-style\"\n" "\n"); atk_obj = gtk_widget_get_accessible(sdd->button); atk_object_set_name (atk_obj, _("Show Desktop Button")); g_signal_connect(G_OBJECT(sdd->button), "button_press_event", G_CALLBACK(do_not_eat_button_press), NULL); g_signal_connect(G_OBJECT(sdd->button), "toggled", G_CALLBACK(button_toggled_callback), sdd); gtk_container_set_border_width(GTK_CONTAINER(sdd->button), 0); gtk_container_add(GTK_CONTAINER(sdd->button), sdd->image); gtk_container_add(GTK_CONTAINER(sdd->applet), sdd->button); g_signal_connect (G_OBJECT(sdd->button), "size_allocate", G_CALLBACK(button_size_allocated), sdd); /* FIXME: Update this comment. */ /* we have to bind change_orient before we do applet_widget_add since we need to get an initial change_orient signal to set our initial oriantation, and we get that during the _add call */ g_signal_connect(G_OBJECT (sdd->applet), "change_orient", G_CALLBACK (applet_change_orient), sdd); mate_panel_applet_set_background_widget(MATE_PANEL_APPLET (sdd->applet), GTK_WIDGET(sdd->applet)); action_group = gtk_action_group_new("ShowDesktop Applet Actions"); gtk_action_group_set_translation_domain(action_group, GETTEXT_PACKAGE); gtk_action_group_add_actions(action_group, show_desktop_menu_actions, G_N_ELEMENTS (show_desktop_menu_actions), sdd); ui_path = g_build_filename(WNCK_MENU_UI_DIR, "showdesktop-menu.xml", NULL); mate_panel_applet_setup_menu_from_file(MATE_PANEL_APPLET(sdd->applet), ui_path, action_group); g_free(ui_path); g_object_unref(action_group); g_signal_connect(G_OBJECT(sdd->applet), "destroy", G_CALLBACK(applet_destroyed), sdd); gtk_drag_dest_set(GTK_WIDGET(sdd->button), 0, NULL, 0, 0); g_signal_connect(G_OBJECT(sdd->button), "drag_motion", G_CALLBACK (button_drag_motion), sdd); g_signal_connect(G_OBJECT(sdd->button), "drag_leave", G_CALLBACK (button_drag_leave), sdd); gtk_widget_show_all(sdd->applet); 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; }
void build_table(charpick_data *p_curr_data) { GtkWidget *box, *button_box, **row_box; GtkWidget *button, *arrow; gint i = 0, len = g_utf8_strlen (p_curr_data->charlist, -1); GtkWidget **toggle_button; gchar *charlist; gint max_width=1, max_height=1; gint size_ratio; toggle_button = g_new (GtkWidget *, len); if (p_curr_data->box) gtk_widget_destroy(p_curr_data->box); if (p_curr_data->panel_vertical) box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); else box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); gtk_widget_show (box); p_curr_data->box = box; button = gtk_button_new (); if (g_list_length (p_curr_data->chartable) != 1) { gtk_widget_set_tooltip_text (button, _("Available palettes")); switch (mate_panel_applet_get_orient (MATE_PANEL_APPLET (p_curr_data->applet))) { case MATE_PANEL_APPLET_ORIENT_DOWN: arrow = gtk_image_new_from_icon_name ("pan-down-symbolic", GTK_ICON_SIZE_MENU); break; case MATE_PANEL_APPLET_ORIENT_UP: arrow = gtk_image_new_from_icon_name ("pan-up-symbolic", GTK_ICON_SIZE_MENU); break; case MATE_PANEL_APPLET_ORIENT_LEFT: arrow = gtk_image_new_from_icon_name ("pan-start-symbolic", GTK_ICON_SIZE_MENU); break; case MATE_PANEL_APPLET_ORIENT_RIGHT: arrow = gtk_image_new_from_icon_name ("pan-end-symbolic", GTK_ICON_SIZE_MENU); break; default: g_assert_not_reached (); } gtk_container_add (GTK_CONTAINER (button), arrow); gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); /* FIXME : evil hack (see force_no_focus_padding) */ #if GTK_CHECK_VERSION (3, 20, 0) force_no_button_padding (button); #else force_no_focus_padding (button); #endif gtk_box_pack_start (GTK_BOX (box), button, TRUE, TRUE, 0); g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (chooser_button_clicked), p_curr_data); g_signal_connect (G_OBJECT (button), "button_press_event", G_CALLBACK (button_press_hack), p_curr_data->applet); } charlist = g_strdup (p_curr_data->charlist); for (i = 0; i < len; i++) { gchar label[7]; GtkRequisition req; gchar *atk_desc; gchar *name; g_utf8_strncpy (label, charlist, 1); charlist = g_utf8_next_char (charlist); #ifdef HAVE_GUCHARMAP /* TRANSLATOR: This sentance reads something like 'Insert "PILCROW SIGN"' * hopefully, the name of the unicode character has already * been translated. */ name = g_strdup_printf (_("Insert \"%s\""), gucharmap_get_unicode_name (g_utf8_get_char (label))); #else name = g_strdup (_("Insert special character")); #endif toggle_button[i] = gtk_toggle_button_new_with_label (label); atk_desc = g_strdup_printf (_("insert special character %s"), label); set_atk_name_description (toggle_button[i], NULL, atk_desc); g_free (atk_desc); gtk_widget_show (toggle_button[i]); gtk_button_set_relief(GTK_BUTTON(toggle_button[i]), GTK_RELIEF_NONE); /* FIXME : evil hack (see force_no_focus_padding) */ #if GTK_CHECK_VERSION (3, 20, 0) force_no_button_padding (toggle_button[i]); #else force_no_focus_padding (toggle_button[i]); #endif gtk_widget_set_tooltip_text (toggle_button[i], name); g_free (name); gtk_widget_get_preferred_size (toggle_button[i], NULL, &req); max_width = MAX (max_width, req.width); max_height = MAX (max_height, req.height-2); g_object_set_data (G_OBJECT (toggle_button[i]), "unichar", GINT_TO_POINTER(g_utf8_get_char (label))); g_signal_connect (G_OBJECT (toggle_button[i]), "toggled", G_CALLBACK (toggle_button_toggled_cb), p_curr_data); g_signal_connect (G_OBJECT (toggle_button[i]), "button_press_event", G_CALLBACK (button_press_hack), p_curr_data->applet); } if (p_curr_data->panel_vertical) { size_ratio = p_curr_data->panel_size / max_width; button_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); } else { size_ratio = p_curr_data->panel_size / max_height; button_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); } gtk_box_set_homogeneous (GTK_BOX (button_box), TRUE); gtk_box_pack_start (GTK_BOX (box), button_box, TRUE, TRUE, 0); size_ratio = MAX (size_ratio, 1); row_box = g_new0 (GtkWidget *, size_ratio); for (i=0; i < size_ratio; i++) { if (!p_curr_data->panel_vertical) row_box[i] = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); else row_box[i] = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); gtk_box_set_homogeneous (GTK_BOX (row_box[i]), TRUE); gtk_box_pack_start (GTK_BOX (button_box), row_box[i], TRUE, TRUE, 0); } for (i = 0; i <len; i++) { int delta = len/size_ratio; int index; if (delta > 0) index = i / delta; else index = i; index = CLAMP (index, 0, size_ratio-1); gtk_box_pack_start (GTK_BOX (row_box[index]), toggle_button[i], TRUE, TRUE, 0); } g_free (toggle_button); gtk_container_add (GTK_CONTAINER(p_curr_data->applet), box); gtk_widget_show_all (p_curr_data->box); p_curr_data->last_index = NO_LAST_INDEX; p_curr_data->last_toggle_button = NULL; }
static gboolean charpicker_applet_fill (MatePanelApplet *applet) { MatePanelAppletOrient orientation; charpick_data *curr_data; GdkAtom utf8_atom; GList *list; gchar *string; GtkActionGroup *action_group; gchar *ui_path; g_set_application_name (_("Character Palette")); gtk_window_set_default_icon_name ("accessories-character-map"); mate_panel_applet_set_background_widget (applet, GTK_WIDGET (applet)); mate_panel_applet_set_flags (applet, MATE_PANEL_APPLET_EXPAND_MINOR); curr_data = g_new0 (charpick_data, 1); curr_data->last_index = NO_LAST_INDEX; curr_data->applet = GTK_WIDGET (applet); curr_data->about_dialog = NULL; curr_data->add_edit_dialog = NULL; curr_data->settings = mate_panel_applet_settings_new (applet, "org.mate.panel.applet.charpick"); get_chartable (curr_data); string = g_settings_get_string (curr_data->settings, "current-list"); if (string) { list = curr_data->chartable; while (list) { if (g_ascii_strcasecmp (list->data, string) == 0) curr_data->charlist = list->data; list = g_list_next (list); } /* FIXME: yeah leak, but this code is full of leaks and evil point shuffling. This should really be rewritten -George */ if (curr_data->charlist == NULL) curr_data->charlist = string; else g_free (string); } else { curr_data->charlist = curr_data->chartable->data; } curr_data->panel_size = mate_panel_applet_get_size (applet); orientation = mate_panel_applet_get_orient (applet); curr_data->panel_vertical = (orientation == MATE_PANEL_APPLET_ORIENT_LEFT) || (orientation == MATE_PANEL_APPLET_ORIENT_RIGHT); build_table (curr_data); g_signal_connect (G_OBJECT (curr_data->applet), "key_press_event", G_CALLBACK (key_press_event), curr_data); utf8_atom = gdk_atom_intern ("UTF8_STRING", FALSE); gtk_selection_add_target (curr_data->applet, GDK_SELECTION_PRIMARY, utf8_atom, 0); gtk_selection_add_target (curr_data->applet, GDK_SELECTION_CLIPBOARD, utf8_atom, 0); g_signal_connect (G_OBJECT (curr_data->applet), "selection_get", G_CALLBACK (charpick_selection_handler), curr_data); g_signal_connect (G_OBJECT (curr_data->applet), "selection_clear_event", G_CALLBACK (selection_clear_cb), curr_data); make_applet_accessible (GTK_WIDGET (applet)); /* session save signal */ g_signal_connect (G_OBJECT (applet), "change_orient", G_CALLBACK (applet_change_orient), curr_data); g_signal_connect (G_OBJECT (applet), "size_allocate", G_CALLBACK (applet_size_allocate), curr_data); g_signal_connect (G_OBJECT (applet), "destroy", G_CALLBACK (applet_destroy), curr_data); gtk_widget_show_all (GTK_WIDGET (applet)); action_group = gtk_action_group_new ("Charpicker Applet Actions"); gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE); gtk_action_group_add_actions (action_group, charpick_applet_menu_actions, G_N_ELEMENTS (charpick_applet_menu_actions), curr_data); ui_path = g_build_filename (CHARPICK_MENU_UI_DIR, "charpick-applet-menu.xml", NULL); mate_panel_applet_setup_menu_from_file (MATE_PANEL_APPLET (applet), ui_path, action_group); g_free (ui_path); if (mate_panel_applet_get_locked_down (MATE_PANEL_APPLET (applet))) { GtkAction *action; action = gtk_action_group_get_action (action_group, "Preferences"); gtk_action_set_visible (action, FALSE); } g_object_unref (action_group); register_stock_for_edit (); populate_menu (curr_data); return TRUE; }
static void gdict_applet_init (GdictApplet *applet) { GdictAppletPrivate *priv; gchar *data_dir; priv = GDICT_APPLET_GET_PRIVATE (applet); applet->priv = priv; if (!priv->loader) priv->loader = gdict_source_loader_new (); /* add our data dir inside $HOME to the loader's search paths */ data_dir = gdict_get_data_dir (); gdict_source_loader_add_search_path (priv->loader, data_dir); g_free (data_dir); gtk_window_set_default_icon_name ("accessories-dictionary"); mate_panel_applet_set_flags (MATE_PANEL_APPLET (applet), MATE_PANEL_APPLET_EXPAND_MINOR); priv->settings = g_settings_new (GDICT_SETTINGS_SCHEMA); priv->desktop_settings = g_settings_new (DESKTOP_SETTINGS_SCHEMA); g_signal_connect (priv->settings, "changed", G_CALLBACK (gdict_applet_settings_changed_cb), applet); g_signal_connect (priv->desktop_settings, "changed", G_CALLBACK (gdict_applet_settings_changed_cb), applet); mate_panel_applet_set_background_widget (MATE_PANEL_APPLET (applet), GTK_WIDGET (applet)); priv->size = mate_panel_applet_get_size (MATE_PANEL_APPLET (applet)); switch (mate_panel_applet_get_orient (MATE_PANEL_APPLET (applet))) { case MATE_PANEL_APPLET_ORIENT_LEFT: case MATE_PANEL_APPLET_ORIENT_RIGHT: priv->orient = GTK_ORIENTATION_VERTICAL; break; case MATE_PANEL_APPLET_ORIENT_UP: case MATE_PANEL_APPLET_ORIENT_DOWN: priv->orient = GTK_ORIENTATION_HORIZONTAL; break; } priv->icon = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (), "accessories-dictionary", 48, 0, NULL); /* force first draw */ gdict_applet_draw (applet); /* force retrieval of the configuration from settings */ gdict_applet_set_source_name (applet, NULL); gdict_applet_set_defbox_font (applet, NULL); gdict_applet_set_print_font (applet, NULL); }