Пример #1
0
static void setup_mateconf(PagerData* pager)
{
	MateConfClient* client;
	char* key;

	client = mateconf_client_get_default();

	key = mate_panel_applet_mateconf_get_full_key(MATE_PANEL_APPLET(pager->applet), "num_rows");
	pager->listeners[0] = mateconf_client_notify_add(client, key, (MateConfClientNotifyFunc) num_rows_changed, pager, NULL, NULL);

	g_free(key);


	key = mate_panel_applet_mateconf_get_full_key(MATE_PANEL_APPLET(pager->applet), "display_workspace_names");
	pager->listeners[1] = mateconf_client_notify_add(client, key, (MateConfClientNotifyFunc) display_workspace_names_changed, pager, NULL, NULL);

	g_free(key);

	key = mate_panel_applet_mateconf_get_full_key(MATE_PANEL_APPLET(pager->applet), "display_all_workspaces");
	pager->listeners[2] = mateconf_client_notify_add(client, key, (MateConfClientNotifyFunc) all_workspaces_changed, pager, NULL, NULL);

	g_free(key);

	g_object_unref(G_OBJECT(client));
}
Пример #2
0
static void
trash_applet_init (TrashApplet *applet)
{
  const GtkTargetEntry drop_types[] = { { "text/uri-list" } };

  /* needed to clamp ourselves to the panel size */
  mate_panel_applet_set_flags (MATE_PANEL_APPLET (applet), MATE_PANEL_APPLET_EXPAND_MINOR);

  /* enable transparency hack */
  mate_panel_applet_set_background_widget (MATE_PANEL_APPLET (applet),
                                      GTK_WIDGET (applet));

  /* setup the image */
  applet->image = g_object_ref_sink (gtk_image_new ());
  gtk_container_add (GTK_CONTAINER (applet),
                     GTK_WIDGET (applet->image));
  gtk_widget_show (GTK_WIDGET (applet->image));

  /* setup the trash backend */
  applet->trash = g_file_new_for_uri ("trash:/");
  applet->trash_monitor = g_file_monitor_file (applet->trash, 0, NULL, NULL);
  g_signal_connect_swapped (applet->trash_monitor, "changed",
                            G_CALLBACK (trash_applet_monitor_changed),
                            applet);

  /* setup drag and drop */
  gtk_drag_dest_set (GTK_WIDGET (applet), GTK_DEST_DEFAULT_ALL,
                     drop_types, G_N_ELEMENTS (drop_types),
                     GDK_ACTION_MOVE);

  /* synthesise the first update */
  applet->items = -1;
  trash_applet_monitor_changed (applet);
}
Пример #3
0
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));
}
Пример #4
0
static void
show_text_toggled (GtkToggleButton *button, gpointer data)
{
  ProgressData   *battstat = data;
  MatePanelApplet *applet = MATE_PANEL_APPLET (battstat->applet);
  
  if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (battstat->radio_text_2))
   && gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (battstat->check_text)))
	  battstat->showtext = APPLET_SHOW_PERCENT;
  else if (gtk_toggle_button_get_active (
			  GTK_TOGGLE_BUTTON (battstat->radio_text_1)) &&
	   gtk_toggle_button_get_active (
		   	  GTK_TOGGLE_BUTTON (battstat->check_text)))
	  battstat->showtext = APPLET_SHOW_TIME;
  else
	  battstat->showtext = APPLET_SHOW_NONE;

  battstat->refresh_label = TRUE;
 
  reconfigure_layout( battstat ); 

  gtk_widget_set_sensitive (GTK_WIDGET (battstat->radio_text_1),
		  battstat->showtext);
  gtk_widget_set_sensitive (GTK_WIDGET (battstat->radio_text_2),
		  battstat->showtext);
	
  mate_panel_applet_mateconf_set_int   (applet, "show_text", 
  				 battstat->showtext, NULL);
}
/**
 * gpm_applet_cb:
 * @_applet: GpmInhibitApplet instance created by the applet factory
 * @iid: Applet id
 *
 * the function called by libmate-panel-applet factory after creation
 **/
static gboolean
gpm_applet_cb (MatePanelApplet *_applet, const gchar *iid, gpointer data)
{
	GpmInhibitApplet *applet = GPM_INHIBIT_APPLET(_applet);
	GtkActionGroup *action_group;
	gchar *ui_path;

	static const GtkActionEntry menu_actions [] = {
		{ "About", GTK_STOCK_ABOUT, N_("_About"),
		  NULL, NULL,
		  G_CALLBACK (gpm_applet_dialog_about_cb) },
		{ "Help", GTK_STOCK_HELP, N_("_Help"),
		  NULL, NULL,
		  G_CALLBACK (gpm_applet_help_cb) }
	};

	if (strcmp (iid, GPM_INHIBIT_APPLET_ID) != 0) {
		return FALSE;
	}

	action_group = gtk_action_group_new ("Inhibit Applet Actions");
	gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
	gtk_action_group_add_actions (action_group,
				      menu_actions,
				      G_N_ELEMENTS (menu_actions),
				      applet);
	ui_path = g_build_filename (INHIBIT_MENU_UI_DIR, "inhibit-applet-menu.xml", NULL);
	mate_panel_applet_setup_menu_from_file (MATE_PANEL_APPLET (applet), ui_path, action_group);
	g_free (ui_path);
	g_object_unref (action_group);

	gpm_applet_draw_cb (applet);
	return TRUE;
}
/**
 * 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);
		}
	}
}
Пример #7
0
static void
cb_dev_selected (GtkComboBox *box,
		 gpointer    data)
{
  MateVolumeAppletPreferences *prefs = data;
  /* MateVolumeApplet *applet = (MateVolumeApplet *) prefs->applet; */
  GtkTreeIter iter;

  if (gtk_combo_box_get_active_iter (box, &iter)) {
    gchar *label;
    MateConfValue *value;

    gtk_tree_model_get (gtk_combo_box_get_model (box),
			&iter, COL_LABEL, &label, -1);

    /* write to mateconf */
    value = mateconf_value_new (MATECONF_VALUE_STRING);
    mateconf_value_set_string (value, label);
    mate_panel_applet_mateconf_set_value (MATE_PANEL_APPLET (prefs->applet),
		      MATE_VOLUME_APPLET_KEY_ACTIVE_ELEMENT,
		      value, NULL);
    g_free (label);
    mateconf_value_free (value);
  }
}
Пример #8
0
static void setup_sensitivity(TasklistData* tasklist, GtkBuilder* builder, const char* wid1, const char* wid2, const char* wid3, const char* key)
{
	MatePanelApplet* applet = MATE_PANEL_APPLET(tasklist->applet);
	GtkWidget* w;

	if (g_settings_is_writable(tasklist->settings, key))
	{
		return;
	}

	w = WID(wid1);
	g_assert(w != NULL);
	gtk_widget_set_sensitive(w, FALSE);

	if (wid2 != NULL)
	{
		w = WID(wid2);
		g_assert(w != NULL);
		gtk_widget_set_sensitive(w, FALSE);
	}

	if (wid3 != NULL)
	{
		w = WID(wid3);
		g_assert(w != NULL);
		gtk_widget_set_sensitive(w, FALSE);
	}
}
Пример #9
0
static void
get_chartable (charpick_data *curr_data)
{
	MatePanelApplet *applet = MATE_PANEL_APPLET (curr_data->applet);
	gint i, n;
	GList *value = NULL;
	
	value = mate_panel_applet_settings_get_glist (curr_data->settings, "chartable");
	if (value) {
		curr_data->chartable = value;
	}
	else {
		n = G_N_ELEMENTS (chartable);
		for (i=0; i<n; i++) {
			gchar *string;
		
			string = g_ucs4_to_utf8 (chartable[i], -1, NULL, NULL, NULL);
			curr_data->chartable = g_list_append (curr_data->chartable, string);
		
		}
		if ( ! g_settings_is_writable (curr_data->settings, "chartable"))
			save_chartable (curr_data);
	}
	

}
/**
 * gpm_inhibit_applet_init:
 * @applet: Inhibit applet instance
 **/
static void
gpm_inhibit_applet_init (GpmInhibitApplet *applet)
{
	DBusGConnection *connection;

	/* initialize fields */
	applet->size = 0;
	applet->icon = NULL;
	applet->cookie = 0;
	applet->connection = NULL;
	applet->proxy = NULL;

	/* Add application specific icons to search path */
	gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (),
                                           GPM_DATA G_DIR_SEPARATOR_S "icons");

	applet->monitor = egg_dbus_monitor_new ();
	g_signal_connect (applet->monitor, "connection-changed",
			  G_CALLBACK (monitor_connection_cb), applet);
	connection = dbus_g_bus_get (DBUS_BUS_SESSION, NULL);
	egg_dbus_monitor_assign (applet->monitor, connection, GS_DBUS_SERVICE);
	gpm_inhibit_applet_dbus_connect (applet);

	/* prepare */
	mate_panel_applet_set_flags (MATE_PANEL_APPLET (applet), MATE_PANEL_APPLET_EXPAND_MINOR);

	/* show */
	gtk_widget_show_all (GTK_WIDGET(applet));

	/* set appropriate size and load icon accordingly */
	gpm_applet_draw_cb (applet);

	/* connect */
	g_signal_connect (G_OBJECT(applet), "button-press-event",
			  G_CALLBACK(gpm_applet_click_cb), NULL);

#if GTK_CHECK_VERSION (3, 0, 0)
	g_signal_connect (G_OBJECT(applet), "draw",
			  G_CALLBACK(gpm_applet_draw_cb), NULL);
#else
	g_signal_connect (G_OBJECT(applet), "expose-event",
			  G_CALLBACK(gpm_applet_draw_cb), NULL);
#endif

	/* We use g_signal_connect_after because letting the panel draw
	 * the background is the only way to have the correct
	 * background when a theme defines a background picture. */
	g_signal_connect_after (G_OBJECT(applet), "expose-event",
				G_CALLBACK(gpm_applet_draw_cb), NULL);

	g_signal_connect (G_OBJECT(applet), "change-background",
			  G_CALLBACK(gpm_applet_change_background_cb), NULL);

	g_signal_connect (G_OBJECT(applet), "change-orient",
			  G_CALLBACK(gpm_applet_draw_cb), NULL);

	g_signal_connect (G_OBJECT(applet), "destroy",
			  G_CALLBACK(gpm_applet_destroy_cb), NULL);
}
Пример #11
0
static gboolean
gdict_applet_entry_button_press_event_cb (GtkWidget      *widget,
					  GdkEventButton *event,
					  GdictApplet    *applet)
{
  mate_panel_applet_request_focus (MATE_PANEL_APPLET (applet), event->time);

  return FALSE;
}
Пример #12
0
static void
full_toggled (GtkToggleButton *button, gpointer data)
{
  ProgressData   *battstat = data;
  MatePanelApplet *applet = MATE_PANEL_APPLET (battstat->applet);
  
  battstat->fullbattnot = gtk_toggle_button_get_active (button);
  mate_panel_applet_mateconf_set_bool   (applet,"full_battery_notification", 
  				 battstat->fullbattnot, NULL);  
}
Пример #13
0
static void
full_toggled (GtkToggleButton *button, gpointer data)
{
  ProgressData   *battstat = data;
  MatePanelApplet *applet = MATE_PANEL_APPLET (battstat->applet);
  
  battstat->fullbattnot = gtk_toggle_button_get_active (button);
  g_settings_set_boolean   (battstat->settings, "full-battery-notification", 
  				 battstat->fullbattnot);  
}
Пример #14
0
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
}
Пример #15
0
static void applet_size_allocate(GtkWidget *widget, GtkAllocation *allocation, TasklistData *tasklist)
{
	int len;
	const int* size_hints;

	size_hints = wnck_tasklist_get_size_hint_list (WNCK_TASKLIST (tasklist->tasklist), &len);

	g_assert(len % 2 == 0);

	mate_panel_applet_set_size_hints(MATE_PANEL_APPLET(tasklist->applet), size_hints, len, 0);
}
Пример #16
0
static void
lowbatt_toggled (GtkToggleButton *button, gpointer data)
{
  ProgressData   *battstat = data;
  MatePanelApplet *applet = MATE_PANEL_APPLET (battstat->applet);
  
  battstat->lowbattnotification = gtk_toggle_button_get_active (button);
  g_settings_set_boolean   (battstat->settings, "low-battery-notification", 
  				 battstat->lowbattnotification);  

  hard_set_sensitive (battstat->hbox_ptr, battstat->lowbattnotification);
}
Пример #17
0
static void
lowbatt_toggled (GtkToggleButton *button, gpointer data)
{
  ProgressData   *battstat = data;
  MatePanelApplet *applet = MATE_PANEL_APPLET (battstat->applet);
  
  battstat->lowbattnotification = gtk_toggle_button_get_active (button);
  mate_panel_applet_mateconf_set_bool   (applet,"low_battery_notification", 
  				 battstat->lowbattnotification, NULL);  

  hard_set_sensitive (battstat->hbox_ptr, battstat->lowbattnotification);
}
Пример #18
0
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);
}
Пример #19
0
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;
}
Пример #20
0
static void
combo_ptr_cb (GtkWidget *combo_ptr, gpointer data)
{
	ProgressData *battstat = data;
	
	if (gtk_combo_box_get_active (GTK_COMBO_BOX (combo_ptr)))
		battstat->red_value_is_time = TRUE;
	else
		battstat->red_value_is_time = FALSE;
	
	mate_panel_applet_mateconf_set_bool (MATE_PANEL_APPLET (battstat->applet),
			"red_value_is_time",
			battstat->red_value_is_time,
			NULL);
}
Пример #21
0
static void
menuitem_activated (GtkMenuItem *menuitem, charpick_data *curr_data)
{
	gchar *string;
	MatePanelApplet *applet = MATE_PANEL_APPLET (curr_data->applet);
	
	string = g_object_get_data (G_OBJECT (menuitem), "string");
	if (g_ascii_strcasecmp (curr_data->charlist, string) == 0)
		return;
	
	curr_data->charlist = string;
	build_table (curr_data);
	if (g_settings_is_writable (curr_data->settings, "current-list"))
		g_settings_set_string (curr_data->settings, "current-list", curr_data->charlist);
}
Пример #22
0
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;
}
Пример #23
0
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;
}
Пример #24
0
static void setup_gsettings(TasklistData* tasklist)
{
	tasklist->settings = mate_panel_applet_settings_new (MATE_PANEL_APPLET (tasklist->applet), WINDOW_LIST_SCHEMA);

	g_signal_connect (tasklist->settings,
					  "changed::display-all-workspaces",
					  G_CALLBACK (display_all_workspaces_changed),
					  tasklist);
	g_signal_connect (tasklist->settings,
					  "changed::group-windows",
					  G_CALLBACK (group_windows_changed),
					  tasklist);
	g_signal_connect (tasklist->settings,
					  "changed::move-unminimized-windows",
					  G_CALLBACK (move_unminimized_windows_changed),
					  tasklist);
}
Пример #25
0
static void
setup_sensitivity(PagerData* pager, GtkBuilder* builder, const char* wid1, const char* wid2, const char* wid3, const char* key)
{
	MatePanelApplet* applet = MATE_PANEL_APPLET(pager->applet);
	MateConfClient* client = mateconf_client_get_default();
	char* fullkey;
	GtkWidget* w;

	if (key[0] == '/')
		fullkey = g_strdup(key);
	else
		fullkey = mate_panel_applet_mateconf_get_full_key(applet, key);

	if (mateconf_client_key_is_writable(client, fullkey, NULL))
	{
		g_object_unref(G_OBJECT(client));
		g_free(fullkey);
		return;
	}

	g_object_unref(G_OBJECT(client));
	g_free(fullkey);

	w = WID(wid1);
	g_assert(w != NULL);
	g_object_set_data(G_OBJECT(w), NEVER_SENSITIVE, GINT_TO_POINTER(1));
	gtk_widget_set_sensitive(w, FALSE);

	if (wid2 != NULL)
	{
		w = WID(wid2);
		g_assert(w != NULL);
		g_object_set_data(G_OBJECT(w), NEVER_SENSITIVE, GINT_TO_POINTER(1));
		gtk_widget_set_sensitive(w, FALSE);
	}

	if (wid3 != NULL)
	{
		w = WID(wid3);
		g_assert(w != NULL);
		g_object_set_data(G_OBJECT(w), NEVER_SENSITIVE, GINT_TO_POINTER(1));
		gtk_widget_set_sensitive(w, FALSE);
	}
}
Пример #26
0
static void applet_size_request(GtkWidget* widget, GtkRequisition* requisition, TasklistData* tasklist)
#endif
{
	int len;
	const int* size_hints;
#if GTK_CHECK_VERSION (3, 0, 0)
	size_hints = wnck_tasklist_get_size_hint_list (WNCK_TASKLIST (tasklist->tasklist), &len);
#else
	GtkRequisition child_req;
	WnckTasklist* wncktl = WNCK_TASKLIST(tasklist->tasklist);

	gtk_widget_get_child_requisition(tasklist->applet, &child_req);

	size_hints = wnck_tasklist_get_size_hint_list(wncktl, &len);
#endif
	g_assert(len % 2 == 0);

	mate_panel_applet_set_size_hints(MATE_PANEL_APPLET(tasklist->applet), size_hints, len, 0);
}
Пример #27
0
static void
radio_ubuntu_toggled (GtkToggleButton *button, gpointer data)
{
  ProgressData   *battstat = data;
  MatePanelApplet *applet = MATE_PANEL_APPLET (battstat->applet);
  gboolean toggled;
  
  toggled = gtk_toggle_button_get_active (button);
  
  /* if (!( toggled || battstat->showtext || battstat->showbattery)) {
    gtk_toggle_button_set_active (button, !toggled);
    return;
  } */
  
  battstat->showstatus = toggled;
  reconfigure_layout( battstat );
  
  mate_panel_applet_mateconf_set_bool   (applet, "show_status", 
  				 battstat->showstatus, NULL);
  				 
}
Пример #28
0
static void
spin_ptr_cb (GtkWidget *spin_ptr, gpointer data)
{
	ProgressData *battstat = data;

	battstat->red_val = gtk_spin_button_get_value_as_int (
			GTK_SPIN_BUTTON (spin_ptr));
	/* automatically calculate orangle and yellow values from the
	 * red value
	 */
	battstat->orange_val = battstat->red_val * ORANGE_MULTIPLIER;
	battstat->orange_val = CLAMP (battstat->orange_val, 0, 100);

	battstat->yellow_val = battstat->red_val * YELLOW_MULTIPLIER;
	battstat->yellow_val = CLAMP (battstat->yellow_val, 0, 100);
	
	mate_panel_applet_mateconf_set_int (MATE_PANEL_APPLET (battstat->applet),
			"red_value",
			battstat->red_val,
			NULL);
}
Пример #29
0
static void
radio_traditional_toggled (GtkToggleButton *button, gpointer data)
{
  ProgressData   *battstat = data;
  MatePanelApplet *applet = MATE_PANEL_APPLET (battstat->applet);
  gboolean toggled;
  
  toggled = gtk_toggle_button_get_active (button);
 
  /* if (!( toggled || battstat->showtext || battstat->showstatus)) {
    gtk_toggle_button_set_active (button, !toggled);
    return;
  } */

  battstat->showbattery = toggled;
  reconfigure_layout( battstat );

  g_settings_set_boolean (battstat->settings, "show-battery", 
  				 battstat->showbattery);
  				 
}
Пример #30
0
static void on_applet_realized(GtkWidget* widget, gpointer user_data)
{
    MatePanelApplet* applet;
    AppletData* data;
    NaTray* tray;
    GtkActionGroup* action_group;
    gchar* ui_path;

    applet = MATE_PANEL_APPLET(widget);
    data = g_object_get_data(G_OBJECT(widget), "system-tray-data");

    if (data != NULL)
    {
        return;
    }

    tray = na_tray_new_for_screen(gtk_widget_get_screen(GTK_WIDGET(applet)), get_orientation_from_applet(applet));

    data = g_slice_new(AppletData);
    data->applet = applet;
    data->tray = tray;

    g_object_set_data_full(G_OBJECT(applet), "system-tray-data", data, (GDestroyNotify) free_applet_data);

    g_signal_connect(applet, "change_orient", G_CALLBACK (applet_change_orientation), data);
    g_signal_connect(applet, "change_background", G_CALLBACK (applet_change_background), data);
    g_signal_connect(applet, "destroy", G_CALLBACK (applet_destroy), data);

    gtk_container_add(GTK_CONTAINER (applet), GTK_WIDGET (tray));
    gtk_widget_show(GTK_WIDGET(tray));

    action_group = gtk_action_group_new("ClockApplet Menu Actions");
    gtk_action_group_set_translation_domain(action_group, GETTEXT_PACKAGE);
    gtk_action_group_add_actions(action_group, menu_actions, G_N_ELEMENTS(menu_actions), data);
    ui_path = g_build_filename(NOTIFICATION_AREA_MENU_UI_DIR, "notification-area-menu.xml", NULL);
    mate_panel_applet_setup_menu_from_file(applet, ui_path, action_group);
    g_free(ui_path);
    g_object_unref(action_group);

}