static TimeOutPlugin*
time_out_new (XfcePanelPlugin *plugin)
{
  TimeOutPlugin *time_out;
  GtkOrientation orientation;

  /* Allocate memory for the plugin structure */
  time_out = panel_slice_new0 (TimeOutPlugin);

  /* Store pointer to the plugin */
  time_out->plugin = plugin;

  /* Create lock screen */
  time_out->lock_screen = time_out_lock_screen_new ();

  /* Connect to 'postpone' signal of the lock screen */
  g_signal_connect (G_OBJECT (time_out->lock_screen), "postpone", G_CALLBACK (time_out_postpone), time_out);

  /* Connect to 'resume' signal of the lock screen */
  g_signal_connect (G_OBJECT (time_out->lock_screen), "resume", G_CALLBACK (time_out_resume), time_out);

  /* Create countdowns */
  time_out->break_countdown = time_out_countdown_new ();
  time_out->lock_countdown = time_out_countdown_new ();

  /* Connect to break countdown signals */
  g_signal_connect (G_OBJECT (time_out->break_countdown), "update", G_CALLBACK (time_out_break_countdown_update), time_out);
  g_signal_connect (G_OBJECT (time_out->break_countdown), "finish", G_CALLBACK (time_out_break_countdown_finish), time_out);

  /* Connect to lock countdown signals */
  g_signal_connect (G_OBJECT (time_out->lock_countdown), "update", G_CALLBACK (time_out_lock_countdown_update), time_out);
  g_signal_connect (G_OBJECT (time_out->lock_countdown), "finish", G_CALLBACK (time_out_lock_countdown_finish), time_out);

  /* Get the current orientation */
  orientation = xfce_panel_plugin_get_orientation (plugin);

  /* Create event box to catch user events */
  time_out->ebox = gtk_event_box_new ();
  gtk_event_box_set_visible_window(GTK_EVENT_BOX(time_out->ebox), FALSE);
  gtk_widget_show (time_out->ebox);

  /* Create flexible box which can do both, horizontal and vertical layout */
  time_out->hvbox = xfce_hvbox_new (orientation, FALSE, 2);
  gtk_container_add (GTK_CONTAINER (time_out->ebox), time_out->hvbox);
  gtk_widget_show (time_out->hvbox);

  /* Create time out icon */
  time_out->panel_icon = gtk_image_new_from_icon_name ("xfce4-time-out-plugin", GTK_ICON_SIZE_DIALOG);
  gtk_image_set_pixel_size (GTK_IMAGE (time_out->panel_icon), xfce_panel_plugin_get_size (time_out->plugin) - 8);
  gtk_box_pack_start (GTK_BOX (time_out->hvbox), time_out->panel_icon, TRUE, TRUE, 0);
  gtk_widget_show (time_out->panel_icon);

  /* Create label for displaying the remaining time until the next break */
  time_out->time_label = gtk_label_new (_("Inactive"));
  gtk_misc_set_alignment (GTK_MISC (time_out->time_label), 0.5, 0.5);
  gtk_box_pack_start (GTK_BOX (time_out->hvbox), time_out->time_label, TRUE, TRUE, 0);
  gtk_widget_show (time_out->time_label);

  return time_out;
}
t_quicklauncher *
quicklauncher_new (XfcePanelPlugin *plugin)
{
	t_quicklauncher *quicklauncher;
	gchar *filename;
	
	DBG ("create quicklauncher");
	quicklauncher = g_new0(t_quicklauncher, 1);
	filename = xfce_panel_plugin_save_location(plugin, TRUE);
	quicklauncher->icon_size = (gint) (0.75 * xfce_panel_plugin_get_size(plugin)/2);
	DBG ("icon size: %d", quicklauncher->icon_size);
	if((!filename) || (!quicklauncher_load_config(quicklauncher, filename) ) )
		quicklauncher_load_default(quicklauncher);

	quicklauncher->orientation = xfce_panel_plugin_get_orientation(plugin);
	quicklauncher->plugin = plugin;
	quicklauncher->table = g_object_ref(gtk_table_new(2, 2, TRUE));
	gtk_table_set_col_spacings(GTK_TABLE(quicklauncher->table), 0);
	gtk_container_add( GTK_CONTAINER(quicklauncher->plugin), quicklauncher->table);
	xfce_panel_plugin_add_action_widget(quicklauncher->plugin, quicklauncher->table);
	gtk_widget_show(quicklauncher->table);

	quicklauncher_organize(quicklauncher);
	return quicklauncher;
}
static void
xfce_xkb_orientation_changed (XfcePanelPlugin *plugin,
                              GtkOrientation orientation,
                              t_xkb *xkb)
{
    xkb_calculate_sizes (xkb, orientation, xfce_panel_plugin_get_size (plugin));
}
static void
xfapplet_setup_empty (XfAppletPlugin *xap)
{
	GtkWidget *img, *eb, *child = NULL;
	GdkPixbuf *pixbuf;
	gint	   size;
	
	size = xfce_panel_plugin_get_size (xap->plugin);
	pixbuf = gdk_pixbuf_new_from_file_at_size (DATADIR "/pixmaps/xfapplet1.svg", size, size, NULL);
	img = gtk_image_new_from_pixbuf (pixbuf);
	g_object_unref (pixbuf);
	gtk_widget_show (img);

	eb = gtk_event_box_new ();
	gtk_container_add (GTK_CONTAINER (eb), img);
	gtk_widget_show (eb);

	child = xfapplet_get_plugin_child (xap->plugin);
	if (child)
		gtk_widget_destroy (child);
	
	gtk_container_add (GTK_CONTAINER(xap->plugin), eb);
	xfce_panel_plugin_add_action_widget (xap->plugin, eb);
	xfce_panel_plugin_menu_show_configure (xap->plugin);
	xfce_panel_plugin_menu_show_about (xap->plugin);

	xap->configured = FALSE;
}
static const gchar*
xfapplet_get_size_string (XfcePanelPlugin *plugin)
{
	gint		 size;
	const gchar	*retval;

	size = xfce_panel_plugin_get_size (plugin);
	size = xfapplet_xfce_size_to_mate_size (size);

        switch (size) {
	case MATE_PANEL_SIZE_XX_SMALL:
                retval = "xx-small";
		break;
	case MATE_PANEL_SIZE_X_SMALL:
		retval = "x-small";
		break;
	case MATE_PANEL_SIZE_SMALL:
                retval = "small";
		break;
	case MATE_PANEL_SIZE_MEDIUM:
                retval = "medium";
		break;
	case MATE_PANEL_SIZE_LARGE:
                retval = "large";
		break;
	case MATE_PANEL_SIZE_X_LARGE:
                retval = "x-large";
		break;
	default:
                retval = "xx-large";
		break;
	}

        return retval;
}
void
quicklauncher_set_nblines(t_quicklauncher *quicklauncher, gint nb_lines)
{
	if (nb_lines != quicklauncher->nb_lines)
	{
		quicklauncher_empty_widgets(quicklauncher);
		quicklauncher->nb_lines = nb_lines;
		quicklauncher_set_size(quicklauncher->plugin,
			xfce_panel_plugin_get_size(quicklauncher->plugin),quicklauncher);
		quicklauncher_organize(quicklauncher);
	}
}
static void fortune_fish_plugin_adjust(fortune_fish_plugin *fish_plugin) {

    fish_plugin->fish->orientation = xfce_panel_plugin_get_orientation(fish_plugin->plugin);
    fish_plugin->fish->size = xfce_panel_plugin_get_size(fish_plugin->plugin);

    if (fish_plugin->fish->orientation == GTK_ORIENTATION_HORIZONTAL) {
        gtk_widget_set_size_request(GTK_WIDGET(fish_plugin->plugin),
                -1, fish_plugin->fish->size);
    } else {
        gtk_widget_set_size_request(GTK_WIDGET(fish_plugin->plugin),
                fish_plugin->fish->size, -1);
    }
}
static void
places_button_resize(PlacesButton *self)
{
    gboolean show_label;
    gint new_size;
    gboolean vertical = FALSE;
#ifdef HAS_PANEL_49
    gboolean deskbar = FALSE;
#endif
    gint nrows = 1;

    if (self->plugin == NULL)
        return;

    new_size = xfce_panel_plugin_get_size(self->plugin);
    self->plugin_size = new_size;
    DBG("Panel size: %d", new_size);

    show_label = self->label_text != NULL;

#ifdef HAS_PANEL_49
  if (xfce_panel_plugin_get_mode(self->plugin) == XFCE_PANEL_PLUGIN_MODE_DESKBAR)
    deskbar = TRUE;
  else if (xfce_panel_plugin_get_mode(self->plugin) == XFCE_PANEL_PLUGIN_MODE_VERTICAL)
    vertical = TRUE;
  nrows = xfce_panel_plugin_get_nrows(self->plugin);
#else
  if (xfce_panel_plugin_get_orientation(self->plugin) == GTK_ORIENTATION_VERTICAL)
    vertical = TRUE;
#endif

    new_size /= nrows;

    if (show_label) {
#ifdef HAS_PANEL_49
        xfce_panel_plugin_set_small (self->plugin, deskbar ? FALSE : TRUE);
#endif
        if (vertical)
          gtk_alignment_set (GTK_ALIGNMENT (self->alignment), 0.5, 0.0, 0.0, 1.0);
        else
          gtk_alignment_set (GTK_ALIGNMENT (self->alignment), 0.0, 0.5, 1.0, 0.0);
    } else {
#ifdef HAS_PANEL_49
        xfce_panel_plugin_set_small(self->plugin, TRUE);
#endif
        gtk_alignment_set (GTK_ALIGNMENT (self->alignment), 0.5, 0.5, 1.0, 1.0);
    }

    /* label */
    places_button_resize_label(self, show_label);
}
Beispiel #9
0
static void macmenu_construct(AppletType* applet)
{
  MacMenu *mmb = g_slice_new0(MacMenu);
  mmb->applet = applet;
  mmb->screen = wnck_screen_get(gdk_screen_get_number(
      gtk_widget_get_screen(GTK_WIDGET(applet))
      ));
  mmb->mbars_scks = g_hash_table_new(NULL, NULL);
  mmb->title_subs = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
  mmb->ts_mtime = 0;

  mmb->basebox = GTK_BOX(gtk_hbox_new(FALSE, 0));
  gtk_container_set_border_width(GTK_CONTAINER(mmb->basebox), 0);
  gtk_container_add(GTK_CONTAINER(applet), GTK_WIDGET(mmb->basebox));

  mmb->label = GTK_LABEL(gtk_label_new(MAIN_LABEL_TEXT));
  PangoAttrList *pattr = pango_attr_list_new();
  PangoAttribute *pa = pango_attr_weight_new(PANGO_WEIGHT_BOLD);
  pa->start_index = 0; pa->end_index = 1024;
  pango_attr_list_insert(pattr, pa);
  gtk_label_set_attributes(mmb->label, pattr);
  pango_attr_list_unref(pattr);
  gtk_label_set_ellipsize(mmb->label, PANGO_ELLIPSIZE_END);
  gtk_label_set_max_width_chars(mmb->label, MAX_LABEL_WIDTH_N_CHARS * 10);
  gtk_label_set_single_line_mode(mmb->label, TRUE);
  gtk_box_pack_start(mmb->basebox, GTK_WIDGET(mmb->label), FALSE, FALSE, 0);

  mmb->label_space = gtk_event_box_new();
  gtk_widget_set_size_request(mmb->label_space, 8, 1);
  gtk_box_pack_start(mmb->basebox, mmb->label_space, FALSE, FALSE, 0);

  mmb->notebook = GTK_NOTEBOOK(gtk_notebook_new());
  gtk_notebook_set_show_tabs(mmb->notebook, FALSE);
  gtk_notebook_set_show_border(mmb->notebook, FALSE);
  gtk_box_pack_start(mmb->basebox, GTK_WIDGET(mmb->notebook), TRUE, TRUE, 0);

  mmb->dummysck = gtk_hbox_new(FALSE, 0);
  gtk_notebook_append_page(mmb->notebook, mmb->dummysck, NULL);

  mmb->mainsck = gtk_hbox_new(FALSE, SHORTCUT_SPACING);
  gtk_notebook_append_page(mmb->notebook, mmb->mainsck, NULL);
  //initialize_mainsck(mmb);

  mmb->button = GTK_BUTTON(gtk_button_new());
  gtk_button_set_relief(mmb->button, GTK_RELIEF_NONE);
  gtk_button_set_focus_on_click(GTK_BUTTON(mmb->button), FALSE);
  gtk_box_pack_start(mmb->basebox, GTK_WIDGET(mmb->button),
                     FALSE, FALSE, 0);

  g_signal_connect(mmb->screen, "active-window-changed",
                   G_CALLBACK(desktop_active_window_changed), mmb);
  g_signal_connect(mmb->screen, "window-opened",
                   G_CALLBACK(desktop_window_opened), mmb);

#ifdef FOR_XFCE
  g_signal_connect(applet, "free-data",
                   G_CALLBACK(macmenu_free_data), mmb);
  g_signal_connect(applet, "size-changed",
                   G_CALLBACK(macmenu_set_size), mmb);
  // setup panel applet
  gtk_widget_show_all(GTK_WIDGET(mmb->basebox));
  xfce_panel_plugin_add_action_widget (applet, GTK_WIDGET(mmb->button));
  xfce_panel_plugin_set_expand(applet, TRUE);
  macmenu_set_size(applet, xfce_panel_plugin_get_size(applet), mmb);
  // load config, set popup
  macmenu_load_from_rc(mmb);
  GtkWidget* label_toggle = gtk_check_menu_item_new_with_label("Hide Label");
  g_signal_connect(label_toggle, "toggled", G_CALLBACK(on_label_toggled), mmb);
  gtk_widget_show(label_toggle);
  gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(label_toggle), mmb->hide_label);
  gtk_check_menu_item_toggled(GTK_CHECK_MENU_ITEM(label_toggle));
  xfce_panel_plugin_menu_insert_item(mmb->applet, GTK_MENU_ITEM(label_toggle));

#elif FOR_GNOME
  g_signal_connect(applet, "destroy", G_CALLBACK(macmenu_free_data), mmb);
  // setup panel applet
  gtk_widget_show_all(GTK_WIDGET(applet));
  g_signal_connect(GTK_WIDGET(mmb->button), "pressed",
                   G_CALLBACK(on_button_pressed), mmb);
  panel_applet_set_flags (applet, PANEL_APPLET_EXPAND_MAJOR);
  macmenu_set_size(applet, panel_applet_get_size(applet), mmb);
  // load config, set popup
  mmb->gconf = gconf_client_get_default();
  macmenu_load_from_gconf(mmb);
  macmenu_write_gconf(mmb);
  static const char toggle_menu_xml [] =
   "<popup name=\"button3\">\n"
   "   <menuitem name=\"hide_label\" "
   "             verb=\"hide_label\" "
   "           _label=\"_Hide Label\"\n"
   "             type=\"toggle\"/>\n"
   "</popup>\n";
  static const BonoboUIVerb toggle_menu_verbs[] =
  {
    BONOBO_UI_VERB_END
  };
  panel_applet_setup_menu(mmb->applet, toggle_menu_xml, toggle_menu_verbs, mmb);
  BonoboUIComponent* popup_component = panel_applet_get_popup_component(mmb->applet);
  bonobo_ui_component_set_prop(popup_component, "/commands/hide_label",
                               "state", mmb->hide_label ? "1": "0", NULL);
  bonobo_ui_component_add_listener(panel_applet_get_popup_component(mmb->applet),
                                   "hide_label",
                                   (BonoboUIListenerFn) on_label_toggled,
                                   mmb);
  on_label_toggled(NULL, NULL, 0, NULL, mmb);
#endif // FOR_XFCE/FOR_GNOME

  add_all(mmb);
  XSetErrorHandler(handle_x_error);
}
static void
screenshot_style_set (XfcePanelPlugin *plugin, gpointer ignored,
                       ScreenshotData *sd)
{
    screenshot_set_size (plugin, xfce_panel_plugin_get_size (plugin), sd);
}
int Plugin::get_size() const
{
  /* Returns the thickness of the panel (i.e. height in the normal
   * orientation or width in the vertical orientation) */
  return xfce_panel_plugin_get_size(xfce_plugin);
}