Browse Source

Initial launcher code

tags/xfce4-panel-4.10.0
Nick Schermer 11 years ago
parent
commit
4f5b94b5a8
6 changed files with 453 additions and 1183 deletions
  1. +1
    -2
      panel-preferences.desktop.in
  2. +5
    -4
      panel/panel-window.c
  3. +49
    -3
      plugins/launcher/launcher-dialog.c
  4. +14
    -5
      plugins/launcher/launcher-dialog.glade
  5. +383
    -1082
      plugins/launcher/launcher.c
  6. +1
    -87
      plugins/launcher/launcher.h

+ 1
- 2
panel-preferences.desktop.in View File

@@ -9,6 +9,5 @@ Categories=X-XFCE;Settings;DesktopSettings;
OnlyShowIn=XFCE;
Terminal=false
StartupNotify=true
_GenericName=Panel Preferences
_Name=Xfce 4 Panel Preferences
_Name=Panel Preferences
_Comment=Customize the Xfce Panel

+ 5
- 4
panel/panel-window.c View File

@@ -70,11 +70,10 @@ static void panel_window_struts_update (PanelWindow *window, gint x, gint y, gi
static void panel_window_set_colormap (PanelWindow *window);
static void panel_window_get_position (PanelWindow *window, gint *root_x, gint *root_y);
static void panel_window_set_borders (PanelWindow *window);
static void panel_window_set_autohide (PanelWindow *window, gboolean autohide);
static void panel_window_set_autohide (PanelWindow *window, gboolean autohide);
static void panel_window_menu_quit (gpointer boolean);
static void panel_window_menu_deactivate (GtkMenu *menu, PanelWindow *window);
static void panel_window_menu_popup (PanelWindow *window);

static void panel_window_set_plugin_active_panel (GtkWidget *widget, gpointer user_data);
static void panel_window_set_plugin_background_alpha (GtkWidget *widget, gpointer user_data);
static void panel_window_set_plugin_size (GtkWidget *widget, gpointer user_data);
@@ -235,7 +234,7 @@ panel_window_class_init (PanelWindowClass *klass)
gtkwidget_class->size_request = panel_window_size_request;
gtkwidget_class->size_allocate = panel_window_size_allocate;
gtkwidget_class->screen_changed = panel_window_screen_changed;
g_object_class_install_property (gobject_class,
PROP_HORIZONTAL,
g_param_spec_boolean ("horizontal", NULL, NULL,
@@ -305,7 +304,9 @@ panel_window_class_init (PanelWindowClass *klass)
g_object_class_install_property (gobject_class,
PROP_SNAP_EDGE,
g_param_spec_uint ("snap-edge", NULL, NULL,
PANEL_SNAP_EGDE_NONE, PANEL_SNAP_EGDE_S, PANEL_SNAP_EGDE_NONE,
PANEL_SNAP_EGDE_NONE,
PANEL_SNAP_EGDE_S,
PANEL_SNAP_EGDE_NONE,
EXO_PARAM_READWRITE));

/* initialize the atoms */


+ 49
- 3
plugins/launcher/launcher-dialog.c View File

@@ -42,6 +42,13 @@ typedef struct
}
LauncherPluginDialog;

enum
{
COL_ADD_ICON,
COL_ADD_NAME,
COL_ADD_FILENAME
};



static gboolean
@@ -66,7 +73,7 @@ launcher_dialog_add_visible_function (GtkTreeModel *model,
text_casefolded = g_utf8_casefold (normalized, -1);
g_free (normalized);

gtk_tree_model_get (model, iter, 0, &name, -1);
gtk_tree_model_get (model, iter, COL_ADD_NAME, &name, -1);
if (G_LIKELY (name != NULL))
{
/* casefold the name */
@@ -97,13 +104,25 @@ launcher_dialog_add_store_insert (gpointer filename,
{
GtkListStore *store = GTK_LIST_STORE (user_data);
GtkTreeIter iter;
const gchar *icon_name;

panel_return_if_fail (XFCE_IS_MENU_ITEM (item));
panel_return_if_fail (GTK_IS_LIST_STORE (user_data));
/* TODO get rid of this and support absolute paths too */
icon_name = xfce_menu_item_get_icon_name (item);
if (icon_name != NULL
&& (g_path_is_absolute (icon_name)
|| !gtk_icon_theme_has_icon (gtk_icon_theme_get_default (), icon_name)))
icon_name = NULL;

/* insert the item */
gtk_list_store_append (store, &iter);
gtk_list_store_set (store, &iter, 0, xfce_menu_item_get_name (item), -1);
gtk_list_store_set (store, &iter,
COL_ADD_ICON, icon_name,
COL_ADD_NAME, xfce_menu_item_get_name (item),
COL_ADD_FILENAME, xfce_menu_item_get_filename (item),
-1);
}


@@ -332,8 +351,31 @@ launcher_dialog_add_response (GtkWidget *widget,
gint response_id,
LauncherPluginDialog *dialog)
{
GObject *treeview, *store;
GtkTreeSelection *selection;
GtkTreeModel *model;
GtkTreeIter iter;
gchar *filename;

panel_return_if_fail (GTK_IS_DIALOG (widget));
panel_return_if_fail (XFCE_IS_LAUNCHER_PLUGIN (dialog->plugin));
if (response_id != 0)
{
/* set the selected item in the treeview */
treeview = gtk_builder_get_object (dialog->builder, "add-treeview");
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview));
if (gtk_tree_selection_get_selected (selection, &model, &iter))
{
gtk_tree_model_get (model, &iter, COL_ADD_FILENAME, &filename, -1);
g_free (filename);
}
}
/* empty the store */
store = gtk_builder_get_object (dialog->builder, "add-store");
gtk_list_store_clear (GTK_LIST_STORE (store));

/* hide the dialog, since it's owned by gtkbuilder */
gtk_widget_hide (widget);
@@ -406,7 +448,7 @@ launcher_dialog_show (LauncherPlugin *plugin)
g_signal_connect (G_OBJECT (object), "delete-event", G_CALLBACK (exo_noop_true), NULL);

object = gtk_builder_get_object (builder, "add-store");
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (object), 0, GTK_SORT_ASCENDING);
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (object), COL_ADD_NAME, GTK_SORT_ASCENDING);

/* setup search filter in the add dialog */
object = gtk_builder_get_object (builder, "add-store-filter");
@@ -414,6 +456,10 @@ launcher_dialog_show (LauncherPlugin *plugin)
gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (object), launcher_dialog_add_visible_function, entry, NULL);
g_signal_connect_swapped (G_OBJECT (entry), "changed", G_CALLBACK (gtk_tree_model_filter_refilter), object);

/* setup the icon size */
object = gtk_builder_get_object (builder, "addrenderericon");
g_object_set (G_OBJECT (object), "stock-size", GTK_ICON_SIZE_DND, NULL);

/* show the dialog */
gtk_widget_show (GTK_WIDGET (window));
}


+ 14
- 5
plugins/launcher/launcher-dialog.glade View File

@@ -31,8 +31,12 @@
</object>
<object class="GtkListStore" id="add-store">
<columns>
<!-- column-name icon -->
<column type="gchararray"/>
<!-- column-name name -->
<column type="gchararray"/>
<!-- column-name filename -->
<column type="gchararray"/>
</columns>
</object>
<object class="GtkTreeModelFilter" id="add-store-filter">
@@ -267,6 +271,7 @@
<child>
<object class="GtkComboBox" id="arrow-position">
<property name="visible">True</property>
<property name="model">arrow-position-store</property>
<property name="button_sensitivity">on</property>
<child>
<object class="GtkCellRendererText" id="cellrenderertext1"/>
@@ -351,7 +356,6 @@
</object>
<object class="XfceTitledDialog" id="dialog-editor">
<property name="title" translatable="yes">Edit Custom Launcher</property>
<property name="modal">True</property>
<property name="window_position">center-on-parent</property>
<property name="destroy_with_parent">True</property>
<property name="icon_name">applications-other</property>
@@ -637,7 +641,6 @@
</object>
<object class="XfceTitledDialog" id="dialog-add">
<property name="title" translatable="yes">Add New Entry</property>
<property name="modal">True</property>
<property name="window_position">center-on-parent</property>
<property name="default_width">400</property>
<property name="default_height">400</property>
@@ -703,11 +706,17 @@
<property name="enable_search">False</property>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn1">
<property name="title">Icon</property>
<property name="spacing">2</property>
<child>
<object class="GtkCellRendererText" id="cellrenderertext1"/>
<object class="GtkCellRendererPixbuf" id="addrenderericon"/>
<attributes>
<attribute name="text">0</attribute>
<attribute name="icon-name">0</attribute>
</attributes>
</child>
<child>
<object class="GtkCellRendererText" id="addrenderername"/>
<attributes>
<attribute name="text">1</attribute>
</attributes>
</child>
</object>


+ 383
- 1082
plugins/launcher/launcher.c
File diff suppressed because it is too large
View File


+ 1
- 87
plugins/launcher/launcher.h View File

@@ -19,15 +19,13 @@
#define __LAUNCHER_H__

#include <gtk/gtk.h>
#include <xfconf/xfconf.h>
#include <libxfce4panel/libxfce4panel.h>

G_BEGIN_DECLS

typedef struct _LauncherPluginClass LauncherPluginClass;
typedef struct _LauncherPlugin LauncherPlugin;
typedef struct _LauncherPluginEntry LauncherPluginEntry;
typedef enum _LauncherPluginArrowPos LauncherPluginArrowPos;
typedef struct _LauncherEntry LauncherEntry;

#define XFCE_TYPE_LAUNCHER_PLUGIN (launcher_plugin_get_type ())
#define XFCE_LAUNCHER_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XFCE_TYPE_LAUNCHER_PLUGIN, LauncherPlugin))
@@ -36,92 +34,8 @@ typedef enum _LauncherPluginArrowPos LauncherPluginArrowPos;
#define XFCE_IS_LAUNCHER_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XFCE_TYPE_LAUNCHER_PLUGIN))
#define XFCE_LAUNCHER_PLUGIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XFCE_TYPE_LAUNCHER_PLUGIN, LauncherPluginClass))

#define LIST_HAS_ONE_ENTRY(list) ((list) != NULL && (list)->next == NULL)
#define LIST_HAS_TWO_OR_MORE_ENTRIES(list) ((list) != NULL && (list)->next != NULL)
#define launcher_plugin_filenames_free(list) G_STMT_START { \
g_slist_foreach (list, (GFunc) g_free, NULL); \
g_slist_free (list); \
} G_STMT_END

enum _LauncherPluginArrowPos
{
ARROW_POS_DEFAULT,
ARROW_POS_LEFT,
ARROW_POS_RIGHT,
ARROW_POS_TOP,
ARROW_POS_BOTTOM,
ARROW_POS_INSIDE_BUTTON,

ARROW_POS_MIN = ARROW_POS_DEFAULT,
ARROW_POS_MAX = ARROW_POS_INSIDE_BUTTON
};

struct _LauncherPluginClass
{
XfcePanelPluginClass __parent__;
};

struct _LauncherPlugin
{
XfcePanelPlugin __parent__;

/* xfconf channel */
XfconfChannel *channel;

/* settings */
guint move_first : 1;
guint disable_tooltips : 1;
guint show_labels : 1;
LauncherPluginArrowPos arrow_position;

/* list of entries in the launcher */
GList *entries;

/* store the icon theme */
GtkIconTheme *icon_theme;

/* plugin widgets */
GtkWidget *box;
GtkWidget *icon_button;
GtkWidget *arrow_button;
GtkWidget *image;
GtkWidget *menu;

/* delayout menu popup */
guint popup_timeout_id;
};

struct _LauncherPluginEntry
{
gchar *name;
gchar *comment;
gchar *exec;
gchar *icon;
gchar *path;

guint terminal : 1;
#ifdef HAVE_LIBSTARTUP_NOTIFICATION
guint startup_notify : 1;
#endif
};

/* target types for dropping in the launcher plugin */
static const GtkTargetEntry drop_targets[] =
{
{ (gchar *) "text/uri-list", 0, 0, },
{ (gchar *) "STRING", 0, 0 },
{ (gchar *) "UTF8_STRING", 0, 0 },
{ (gchar *) "text/plain", 0, 0 },
};

GType launcher_plugin_get_type (void) G_GNUC_CONST;

void launcher_plugin_rebuild (LauncherPlugin *plugin, gboolean update_icon);

GSList *launcher_plugin_filenames_from_selection_data (GtkSelectionData *selection_data);

GdkPixbuf *launcher_plugin_load_pixbuf (const gchar *name, gint size, GtkIconTheme *icon_theme);

G_END_DECLS

#endif /* !__LAUNCHER_H__ */

Loading…
Cancel
Save