time-plugin: Port to WindowActivatable
This commit is contained in:
parent
30a61a9fd8
commit
33cb6f4b32
|
@ -3,14 +3,16 @@ DIST_SUBDIRS = \
|
||||||
filebrowser \
|
filebrowser \
|
||||||
modelines \
|
modelines \
|
||||||
sort \
|
sort \
|
||||||
spell
|
spell \
|
||||||
|
time
|
||||||
|
|
||||||
SUBDIRS = \
|
SUBDIRS = \
|
||||||
docinfo \
|
docinfo \
|
||||||
filebrowser \
|
filebrowser \
|
||||||
modelines \
|
modelines \
|
||||||
sort \
|
sort \
|
||||||
spell
|
spell \
|
||||||
|
time
|
||||||
|
|
||||||
if ENABLE_ENCHANT
|
if ENABLE_ENCHANT
|
||||||
SUBDIRS += spell
|
SUBDIRS += spell
|
||||||
|
|
|
@ -16,8 +16,6 @@
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
|
||||||
* $Id$
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -38,12 +36,11 @@
|
||||||
|
|
||||||
#include <glib/gi18n-lib.h>
|
#include <glib/gi18n-lib.h>
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <gmodule.h>
|
|
||||||
#include <gio/gio.h>
|
#include <gio/gio.h>
|
||||||
#include <libpeas/peas-activatable.h>
|
|
||||||
#include <libpeas-gtk/peas-gtk-configurable.h>
|
|
||||||
|
|
||||||
#include <xed/xed-window.h>
|
#include <xed/xed-window.h>
|
||||||
|
#include <xed/xed-window-activatable.h>
|
||||||
|
#include <libpeas-gtk/peas-gtk-configurable.h>
|
||||||
#include <xed/xed-debug.h>
|
#include <xed/xed-debug.h>
|
||||||
#include <xed/xed-utils.h>
|
#include <xed/xed-utils.h>
|
||||||
|
|
||||||
|
@ -104,9 +101,17 @@ enum
|
||||||
NUM_COLUMNS
|
NUM_COLUMNS
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct _TimeConfigureDialog TimeConfigureDialog;
|
typedef enum
|
||||||
|
{
|
||||||
|
PROMPT_SELECTED_FORMAT = 0, /* Popup dialog with list preselected */
|
||||||
|
PROMPT_CUSTOM_FORMAT, /* Popup dialog with entry preselected */
|
||||||
|
USE_SELECTED_FORMAT, /* Use selected format directly */
|
||||||
|
USE_CUSTOM_FORMAT /* Use custom format directly */
|
||||||
|
} XedTimePluginPromptType;
|
||||||
|
|
||||||
struct _TimeConfigureDialog
|
typedef struct _TimeConfigureWidget TimeConfigureWidget;
|
||||||
|
|
||||||
|
struct _TimeConfigureWidget
|
||||||
{
|
{
|
||||||
GtkWidget *content;
|
GtkWidget *content;
|
||||||
|
|
||||||
|
@ -144,17 +149,9 @@ struct _ChooseFormatDialog
|
||||||
GSettings *settings;
|
GSettings *settings;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
PROMPT_SELECTED_FORMAT = 0, /* Popup dialog with list preselected */
|
|
||||||
PROMPT_CUSTOM_FORMAT, /* Popup dialog with entry preselected */
|
|
||||||
USE_SELECTED_FORMAT, /* Use selected format directly */
|
|
||||||
USE_CUSTOM_FORMAT /* Use custom format directly */
|
|
||||||
} XedTimePluginPromptType;
|
|
||||||
|
|
||||||
struct _XedTimePluginPrivate
|
struct _XedTimePluginPrivate
|
||||||
{
|
{
|
||||||
GtkWidget *window;
|
XedWindow *window;
|
||||||
|
|
||||||
GSettings *settings;
|
GSettings *settings;
|
||||||
|
|
||||||
|
@ -165,22 +162,23 @@ struct _XedTimePluginPrivate
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
PROP_0,
|
PROP_0,
|
||||||
PROP_OBJECT
|
PROP_WINDOW
|
||||||
};
|
};
|
||||||
|
|
||||||
static void peas_activatable_iface_init (PeasActivatableInterface *iface);
|
static void xed_window_activatable_iface_init (XedWindowActivatableInterface *iface);
|
||||||
static void peas_gtk_configurable_iface_init (PeasGtkConfigurableInterface *iface);
|
static void peas_gtk_configurable_iface_init (PeasGtkConfigurableInterface *iface);
|
||||||
|
|
||||||
G_DEFINE_DYNAMIC_TYPE_EXTENDED (XedTimePlugin,
|
G_DEFINE_DYNAMIC_TYPE_EXTENDED (XedTimePlugin,
|
||||||
xed_time_plugin,
|
xed_time_plugin,
|
||||||
PEAS_TYPE_EXTENSION_BASE,
|
PEAS_TYPE_EXTENSION_BASE,
|
||||||
0,
|
0,
|
||||||
G_IMPLEMENT_INTERFACE_DYNAMIC (PEAS_TYPE_ACTIVATABLE,
|
G_IMPLEMENT_INTERFACE_DYNAMIC (XED_TYPE_WINDOW_ACTIVATABLE,
|
||||||
peas_activatable_iface_init)
|
xed_window_activatable_iface_init)
|
||||||
G_IMPLEMENT_INTERFACE_DYNAMIC (PEAS_GTK_TYPE_CONFIGURABLE,
|
G_IMPLEMENT_INTERFACE_DYNAMIC (PEAS_GTK_TYPE_CONFIGURABLE,
|
||||||
peas_gtk_configurable_iface_init))
|
peas_gtk_configurable_iface_init))
|
||||||
|
|
||||||
static void time_cb (GtkAction *action, XedTimePlugin *plugin);
|
static void time_cb (GtkAction *action,
|
||||||
|
XedTimePlugin *plugin);
|
||||||
|
|
||||||
static const GtkActionEntry action_entries[] =
|
static const GtkActionEntry action_entries[] =
|
||||||
{
|
{
|
||||||
|
@ -223,132 +221,79 @@ xed_time_plugin_dispose (GObject *object)
|
||||||
|
|
||||||
xed_debug_message (DEBUG_PLUGINS, "XedTimePlugin disposing");
|
xed_debug_message (DEBUG_PLUGINS, "XedTimePlugin disposing");
|
||||||
|
|
||||||
if (plugin->priv->window != NULL)
|
g_clear_object (&plugin->priv->window);
|
||||||
{
|
g_clear_object (&plugin->priv->action_group);
|
||||||
g_object_unref (plugin->priv->window);
|
|
||||||
plugin->priv->window = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (plugin->priv->action_group)
|
|
||||||
{
|
|
||||||
g_object_unref (plugin->priv->action_group);
|
|
||||||
plugin->priv->action_group = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
G_OBJECT_CLASS (xed_time_plugin_parent_class)->dispose (object);
|
G_OBJECT_CLASS (xed_time_plugin_parent_class)->dispose (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
update_ui (XedTimePluginPrivate *data)
|
update_ui (XedTimePlugin *plugin)
|
||||||
{
|
{
|
||||||
XedWindow *window;
|
|
||||||
XedView *view;
|
XedView *view;
|
||||||
GtkAction *action;
|
GtkAction *action;
|
||||||
|
|
||||||
xed_debug (DEBUG_PLUGINS);
|
xed_debug (DEBUG_PLUGINS);
|
||||||
|
|
||||||
window = XED_WINDOW (data->window);
|
view = xed_window_get_active_view (plugin->priv->window);
|
||||||
view = xed_window_get_active_view (window);
|
|
||||||
|
|
||||||
xed_debug_message (DEBUG_PLUGINS, "View: %p", view);
|
xed_debug_message (DEBUG_PLUGINS, "View: %p", view);
|
||||||
|
|
||||||
action = gtk_action_group_get_action (data->action_group,
|
action = gtk_action_group_get_action (plugin->priv->action_group, "InsertDateAndTime");
|
||||||
"InsertDateAndTime");
|
gtk_action_set_sensitive (action, (view != NULL) && gtk_text_view_get_editable (GTK_TEXT_VIEW (view)));
|
||||||
gtk_action_set_sensitive (action,
|
|
||||||
(view != NULL) &&
|
|
||||||
gtk_text_view_get_editable (GTK_TEXT_VIEW (view)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
xed_time_plugin_activate (PeasActivatable *activatable)
|
xed_time_plugin_activate (XedWindowActivatable *activatable)
|
||||||
{
|
{
|
||||||
XedTimePlugin *plugin;
|
XedTimePluginPrivate *priv;
|
||||||
XedTimePluginPrivate *data;
|
|
||||||
XedWindow *window;
|
|
||||||
GtkUIManager *manager;
|
GtkUIManager *manager;
|
||||||
|
|
||||||
xed_debug (DEBUG_PLUGINS);
|
xed_debug (DEBUG_PLUGINS);
|
||||||
|
|
||||||
plugin = XED_TIME_PLUGIN (activatable);
|
priv = XED_TIME_PLUGIN (activatable)->priv;
|
||||||
data = plugin->priv;
|
manager = xed_window_get_ui_manager (priv->window);
|
||||||
window = XED_WINDOW (data->window);
|
|
||||||
|
|
||||||
manager = xed_window_get_ui_manager (window);
|
priv->action_group = gtk_action_group_new ("XedTimePluginActions");
|
||||||
|
gtk_action_group_set_translation_domain (priv->action_group, GETTEXT_PACKAGE);
|
||||||
|
gtk_action_group_add_actions (priv->action_group, action_entries, G_N_ELEMENTS (action_entries), activatable);
|
||||||
|
|
||||||
data->action_group = gtk_action_group_new ("XedTimePluginActions");
|
gtk_ui_manager_insert_action_group (manager, priv->action_group, -1);
|
||||||
gtk_action_group_set_translation_domain (data->action_group,
|
|
||||||
GETTEXT_PACKAGE);
|
|
||||||
gtk_action_group_add_actions (data->action_group,
|
|
||||||
action_entries,
|
|
||||||
G_N_ELEMENTS (action_entries),
|
|
||||||
plugin);
|
|
||||||
|
|
||||||
gtk_ui_manager_insert_action_group (manager, data->action_group, -1);
|
priv->ui_id = gtk_ui_manager_new_merge_id (manager);
|
||||||
|
|
||||||
data->ui_id = gtk_ui_manager_new_merge_id (manager);
|
|
||||||
|
|
||||||
gtk_ui_manager_add_ui (manager,
|
gtk_ui_manager_add_ui (manager,
|
||||||
data->ui_id,
|
priv->ui_id,
|
||||||
MENU_PATH,
|
MENU_PATH,
|
||||||
"InsertDateAndTime",
|
"InsertDateAndTime",
|
||||||
"InsertDateAndTime",
|
"InsertDateAndTime",
|
||||||
GTK_UI_MANAGER_MENUITEM,
|
GTK_UI_MANAGER_MENUITEM,
|
||||||
FALSE);
|
FALSE);
|
||||||
|
|
||||||
update_ui (data);
|
update_ui (XED_TIME_PLUGIN (activatable));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
xed_time_plugin_deactivate (PeasActivatable *activatable)
|
xed_time_plugin_deactivate (XedWindowActivatable *activatable)
|
||||||
{
|
{
|
||||||
XedTimePluginPrivate *data;
|
XedTimePluginPrivate *priv;
|
||||||
XedWindow *window;
|
|
||||||
GtkUIManager *manager;
|
GtkUIManager *manager;
|
||||||
|
|
||||||
xed_debug (DEBUG_PLUGINS);
|
xed_debug (DEBUG_PLUGINS);
|
||||||
|
|
||||||
data = XED_TIME_PLUGIN (activatable)->priv;
|
priv = XED_TIME_PLUGIN (activatable)->priv;
|
||||||
window = XED_WINDOW (data->window);
|
manager = xed_window_get_ui_manager (priv->window);
|
||||||
|
|
||||||
manager = xed_window_get_ui_manager (window);
|
gtk_ui_manager_remove_ui (manager, priv->ui_id);
|
||||||
|
gtk_ui_manager_remove_action_group (manager, priv->action_group);
|
||||||
gtk_ui_manager_remove_ui (manager, data->ui_id);
|
|
||||||
gtk_ui_manager_remove_action_group (manager, data->action_group);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
xed_time_plugin_update_state (PeasActivatable *activatable)
|
xed_time_plugin_update_state (XedWindowActivatable *activatable)
|
||||||
{
|
{
|
||||||
xed_debug (DEBUG_PLUGINS);
|
xed_debug (DEBUG_PLUGINS);
|
||||||
|
|
||||||
update_ui (XED_TIME_PLUGIN (activatable)->priv);
|
update_ui (XED_TIME_PLUGIN (activatable));
|
||||||
}
|
|
||||||
|
|
||||||
/* whether we should prompt the user or use the specified format */
|
|
||||||
static XedTimePluginPromptType
|
|
||||||
get_prompt_type (XedTimePlugin *plugin)
|
|
||||||
{
|
|
||||||
XedTimePluginPromptType prompt_type;
|
|
||||||
|
|
||||||
prompt_type = g_settings_get_enum (plugin->priv->settings,
|
|
||||||
PROMPT_TYPE_KEY);
|
|
||||||
|
|
||||||
return prompt_type;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
set_prompt_type (GSettings *settings,
|
|
||||||
XedTimePluginPromptType prompt_type)
|
|
||||||
{
|
|
||||||
if (!g_settings_is_writable (settings,
|
|
||||||
PROMPT_TYPE_KEY))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_settings_set_enum (settings,
|
|
||||||
PROMPT_TYPE_KEY,
|
|
||||||
prompt_type);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The selected format in the list */
|
/* The selected format in the list */
|
||||||
|
@ -357,28 +302,24 @@ get_selected_format (XedTimePlugin *plugin)
|
||||||
{
|
{
|
||||||
gchar *sel_format;
|
gchar *sel_format;
|
||||||
|
|
||||||
sel_format = g_settings_get_string (plugin->priv->settings,
|
sel_format = g_settings_get_string (plugin->priv->settings, SELECTED_FORMAT_KEY);
|
||||||
SELECTED_FORMAT_KEY);
|
|
||||||
|
|
||||||
return sel_format ? sel_format : g_strdup (formats [0]);
|
return sel_format ? sel_format : g_strdup (formats [0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
// static void
|
||||||
set_selected_format (GSettings *settings,
|
// set_selected_format (XedTimePlugin *plugin,
|
||||||
const gchar *format)
|
// const gchar *format)
|
||||||
{
|
// {
|
||||||
g_return_if_fail (format != NULL);
|
// g_return_if_fail (format != NULL);
|
||||||
|
|
||||||
if (!g_settings_is_writable (settings,
|
// if (!g_settings_is_writable (plugin->priv->settings, SELECTED_FORMAT_KEY))
|
||||||
SELECTED_FORMAT_KEY))
|
// {
|
||||||
{
|
// return;
|
||||||
return;
|
// }
|
||||||
}
|
|
||||||
|
|
||||||
g_settings_set_string (settings,
|
// g_settings_set_string (settings, SELECTED_FORMAT_KEY, format);
|
||||||
SELECTED_FORMAT_KEY,
|
// }
|
||||||
format);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* the custom format in the entry */
|
/* the custom format in the entry */
|
||||||
static gchar *
|
static gchar *
|
||||||
|
@ -386,26 +327,24 @@ get_custom_format (XedTimePlugin *plugin)
|
||||||
{
|
{
|
||||||
gchar *format;
|
gchar *format;
|
||||||
|
|
||||||
format = g_settings_get_string (plugin->priv->settings,
|
format = g_settings_get_string (plugin->priv->settings, CUSTOM_FORMAT_KEY);
|
||||||
CUSTOM_FORMAT_KEY);
|
|
||||||
|
|
||||||
return format ? format : g_strdup (DEFAULT_CUSTOM_FORMAT);
|
return format ? format : g_strdup (DEFAULT_CUSTOM_FORMAT);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
// static void
|
||||||
set_custom_format (GSettings *settings,
|
// set_custom_format (XedTimePlugin *plugin,
|
||||||
const gchar *format)
|
// const gchar *format)
|
||||||
{
|
// {
|
||||||
g_return_if_fail (format != NULL);
|
// g_return_if_fail (format != NULL);
|
||||||
|
|
||||||
if (!g_settings_is_writable (settings,
|
// if (!g_settings_is_writable (plugin->priv->settings, CUSTOM_FORMAT_KEY))
|
||||||
CUSTOM_FORMAT_KEY))
|
// {
|
||||||
return;
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
g_settings_set_string (settings,
|
// g_settings_set_string (plugin->priv->settings, CUSTOM_FORMAT_KEY, format);
|
||||||
CUSTOM_FORMAT_KEY,
|
// }
|
||||||
format);
|
|
||||||
}
|
|
||||||
|
|
||||||
static gchar *
|
static gchar *
|
||||||
get_time (const gchar* format)
|
get_time (const gchar* format)
|
||||||
|
@ -422,11 +361,15 @@ get_time (const gchar* format)
|
||||||
g_return_val_if_fail (format != NULL, NULL);
|
g_return_val_if_fail (format != NULL, NULL);
|
||||||
|
|
||||||
if (strlen (format) == 0)
|
if (strlen (format) == 0)
|
||||||
|
{
|
||||||
return g_strdup (" ");
|
return g_strdup (" ");
|
||||||
|
}
|
||||||
|
|
||||||
locale_format = g_locale_from_utf8 (format, -1, NULL, NULL, NULL);
|
locale_format = g_locale_from_utf8 (format, -1, NULL, NULL, NULL);
|
||||||
if (locale_format == NULL)
|
if (locale_format == NULL)
|
||||||
|
{
|
||||||
return g_strdup (" ");
|
return g_strdup (" ");
|
||||||
|
}
|
||||||
|
|
||||||
clock = time (NULL);
|
clock = time (NULL);
|
||||||
now = localtime (&clock);
|
now = localtime (&clock);
|
||||||
|
@ -450,22 +393,26 @@ get_time (const gchar* format)
|
||||||
g_free (out);
|
g_free (out);
|
||||||
|
|
||||||
if (out_utf8 == NULL)
|
if (out_utf8 == NULL)
|
||||||
|
{
|
||||||
out_utf8 = g_strdup (" ");
|
out_utf8 = g_strdup (" ");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return out_utf8;
|
return out_utf8;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
configure_dialog_destroyed (GtkWidget *widget,
|
configure_widget_destroyed (GtkWidget *widget,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
TimeConfigureDialog *dialog = (TimeConfigureDialog *) data;
|
TimeConfigureWidget *conf_widget = (TimeConfigureWidget *) data;
|
||||||
|
|
||||||
xed_debug (DEBUG_PLUGINS);
|
xed_debug (DEBUG_PLUGINS);
|
||||||
|
|
||||||
g_object_unref (dialog->settings);
|
g_object_unref (conf_widget->settings);
|
||||||
g_slice_free (TimeConfigureDialog, data);
|
g_slice_free (TimeConfigureWidget, data);
|
||||||
|
|
||||||
|
xed_debug_message (DEBUG_PLUGINS, "END");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -475,6 +422,8 @@ choose_format_dialog_destroyed (GtkWidget *widget,
|
||||||
xed_debug (DEBUG_PLUGINS);
|
xed_debug (DEBUG_PLUGINS);
|
||||||
|
|
||||||
g_slice_free (ChooseFormatDialog, data);
|
g_slice_free (ChooseFormatDialog, data);
|
||||||
|
|
||||||
|
xed_debug_message (DEBUG_PLUGINS, "END");
|
||||||
}
|
}
|
||||||
|
|
||||||
static GtkTreeModel *
|
static GtkTreeModel *
|
||||||
|
@ -493,8 +442,7 @@ create_model (GtkWidget *listview,
|
||||||
store = gtk_list_store_new (NUM_COLUMNS, G_TYPE_STRING, G_TYPE_INT);
|
store = gtk_list_store_new (NUM_COLUMNS, G_TYPE_STRING, G_TYPE_INT);
|
||||||
|
|
||||||
/* Set tree view model*/
|
/* Set tree view model*/
|
||||||
gtk_tree_view_set_model (GTK_TREE_VIEW (listview),
|
gtk_tree_view_set_model (GTK_TREE_VIEW (listview), GTK_TREE_MODEL (store));
|
||||||
GTK_TREE_MODEL (store));
|
|
||||||
g_object_unref (G_OBJECT (store));
|
g_object_unref (G_OBJECT (store));
|
||||||
|
|
||||||
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (listview));
|
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (listview));
|
||||||
|
@ -512,14 +460,13 @@ create_model (GtkWidget *listview,
|
||||||
|
|
||||||
xed_debug_message (DEBUG_PLUGINS, "%d : %s", i, str);
|
xed_debug_message (DEBUG_PLUGINS, "%d : %s", i, str);
|
||||||
gtk_list_store_append (store, &iter);
|
gtk_list_store_append (store, &iter);
|
||||||
gtk_list_store_set (store, &iter,
|
gtk_list_store_set (store, &iter, COLUMN_FORMATS, str, COLUMN_INDEX, i, -1);
|
||||||
COLUMN_FORMATS, str,
|
|
||||||
COLUMN_INDEX, i,
|
|
||||||
-1);
|
|
||||||
g_free (str);
|
g_free (str);
|
||||||
|
|
||||||
if (sel_format && strcmp (formats[i], sel_format) == 0)
|
if (sel_format && strcmp (formats[i], sel_format) == 0)
|
||||||
|
{
|
||||||
gtk_tree_selection_select_iter (selection, &iter);
|
gtk_tree_selection_select_iter (selection, &iter);
|
||||||
|
}
|
||||||
|
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
|
@ -557,8 +504,7 @@ scroll_to_selected (GtkTreeView *tree_view)
|
||||||
path = gtk_tree_model_get_path (model, &iter);
|
path = gtk_tree_model_get_path (model, &iter);
|
||||||
g_return_if_fail (path != NULL);
|
g_return_if_fail (path != NULL);
|
||||||
|
|
||||||
gtk_tree_view_scroll_to_cell (tree_view,
|
gtk_tree_view_scroll_to_cell (tree_view, path, NULL, TRUE, 1.0, 0.0);
|
||||||
path, NULL, TRUE, 1.0, 0.0);
|
|
||||||
gtk_tree_path_free (path);
|
gtk_tree_path_free (path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -578,8 +524,7 @@ create_formats_list (GtkWidget *listview,
|
||||||
|
|
||||||
/* the Available formats column */
|
/* the Available formats column */
|
||||||
cell = gtk_cell_renderer_text_new ();
|
cell = gtk_cell_renderer_text_new ();
|
||||||
column = gtk_tree_view_column_new_with_attributes (
|
column = gtk_tree_view_column_new_with_attributes (_("Available formats"),
|
||||||
_("Available formats"),
|
|
||||||
cell,
|
cell,
|
||||||
"text", COLUMN_FORMATS,
|
"text", COLUMN_FORMATS,
|
||||||
NULL);
|
NULL);
|
||||||
|
@ -588,10 +533,8 @@ create_formats_list (GtkWidget *listview,
|
||||||
/* Create model, it also add model to the tree view */
|
/* Create model, it also add model to the tree view */
|
||||||
create_model (listview, sel_format, plugin);
|
create_model (listview, sel_format, plugin);
|
||||||
|
|
||||||
g_signal_connect (listview,
|
g_signal_connect (listview, "realize",
|
||||||
"realize",
|
G_CALLBACK (scroll_to_selected), NULL);
|
||||||
G_CALLBACK (scroll_to_selected),
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
gtk_widget_show (listview);
|
gtk_widget_show (listview);
|
||||||
}
|
}
|
||||||
|
@ -635,54 +578,60 @@ choose_format_dialog_button_toggled (GtkToggleButton *button,
|
||||||
gtk_widget_set_sensitive (dialog->list, FALSE);
|
gtk_widget_set_sensitive (dialog->list, FALSE);
|
||||||
gtk_widget_set_sensitive (dialog->custom_entry, TRUE);
|
gtk_widget_set_sensitive (dialog->custom_entry, TRUE);
|
||||||
gtk_widget_set_sensitive (dialog->custom_format_example, TRUE);
|
gtk_widget_set_sensitive (dialog->custom_format_example, TRUE);
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->use_list)))
|
else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->use_list)))
|
||||||
{
|
{
|
||||||
gtk_widget_set_sensitive (dialog->list, TRUE);
|
gtk_widget_set_sensitive (dialog->list, TRUE);
|
||||||
gtk_widget_set_sensitive (dialog->custom_entry, FALSE);
|
gtk_widget_set_sensitive (dialog->custom_entry, FALSE);
|
||||||
gtk_widget_set_sensitive (dialog->custom_format_example, FALSE);
|
gtk_widget_set_sensitive (dialog->custom_format_example, FALSE);
|
||||||
|
}
|
||||||
return;
|
else
|
||||||
|
{
|
||||||
|
g_return_if_reached ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
configure_dialog_button_toggled (GtkToggleButton *button, TimeConfigureDialog *dialog)
|
configure_widget_button_toggled (GtkToggleButton *button,
|
||||||
|
TimeConfigureWidget *conf_widget)
|
||||||
{
|
{
|
||||||
|
XedTimePluginPromptType prompt_type;
|
||||||
|
|
||||||
xed_debug (DEBUG_PLUGINS);
|
xed_debug (DEBUG_PLUGINS);
|
||||||
|
|
||||||
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->custom)))
|
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (conf_widget->custom)))
|
||||||
{
|
{
|
||||||
gtk_widget_set_sensitive (dialog->list, FALSE);
|
gtk_widget_set_sensitive (conf_widget->list, FALSE);
|
||||||
gtk_widget_set_sensitive (dialog->custom_entry, TRUE);
|
gtk_widget_set_sensitive (conf_widget->custom_entry, TRUE);
|
||||||
gtk_widget_set_sensitive (dialog->custom_format_example, TRUE);
|
gtk_widget_set_sensitive (conf_widget->custom_format_example, TRUE);
|
||||||
|
|
||||||
set_prompt_type (dialog->settings, USE_CUSTOM_FORMAT);
|
prompt_type = USE_CUSTOM_FORMAT;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->use_list)))
|
else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (conf_widget->use_list)))
|
||||||
{
|
{
|
||||||
gtk_widget_set_sensitive (dialog->list, TRUE);
|
gtk_widget_set_sensitive (conf_widget->list, TRUE);
|
||||||
gtk_widget_set_sensitive (dialog->custom_entry, FALSE);
|
gtk_widget_set_sensitive (conf_widget->custom_entry, FALSE);
|
||||||
gtk_widget_set_sensitive (dialog->custom_format_example, FALSE);
|
gtk_widget_set_sensitive (conf_widget->custom_format_example, FALSE);
|
||||||
|
|
||||||
set_prompt_type (dialog->settings, USE_SELECTED_FORMAT);
|
prompt_type = USE_SELECTED_FORMAT;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->prompt)))
|
else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (conf_widget->prompt)))
|
||||||
{
|
{
|
||||||
gtk_widget_set_sensitive (dialog->list, FALSE);
|
gtk_widget_set_sensitive (conf_widget->list, FALSE);
|
||||||
gtk_widget_set_sensitive (dialog->custom_entry, FALSE);
|
gtk_widget_set_sensitive (conf_widget->custom_entry, FALSE);
|
||||||
gtk_widget_set_sensitive (dialog->custom_format_example, FALSE);
|
gtk_widget_set_sensitive (conf_widget->custom_format_example, FALSE);
|
||||||
|
|
||||||
set_prompt_type (dialog->settings, PROMPT_SELECTED_FORMAT);
|
prompt_type = PROMPT_SELECTED_FORMAT;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
g_return_if_reached ();
|
||||||
|
}
|
||||||
|
|
||||||
|
g_settings_set_enum (conf_widget->settings, PROMPT_TYPE_KEY, prompt_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gint
|
static gint
|
||||||
|
@ -714,27 +663,36 @@ get_format_from_list (GtkWidget *listview)
|
||||||
g_return_val_if_reached (0);
|
g_return_val_if_reached (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// static void
|
||||||
|
// configure_dialog_selection_changed (GtkTreeSelection *selection,
|
||||||
|
// TimeConfigureDialog *dialog)
|
||||||
|
// {
|
||||||
|
// gint sel_format;
|
||||||
|
|
||||||
|
// sel_format = get_format_from_list (dialog->list);
|
||||||
|
// set_selected_format (dialog->settings, formats[sel_format]);
|
||||||
|
// }
|
||||||
|
|
||||||
static void
|
static void
|
||||||
configure_dialog_selection_changed (GtkTreeSelection *selection,
|
on_configure_widget_selection_changed (GtkTreeSelection *selection,
|
||||||
TimeConfigureDialog *dialog)
|
TimeConfigureWidget *conf_widget)
|
||||||
{
|
{
|
||||||
gint sel_format;
|
gint sel_format;
|
||||||
|
|
||||||
sel_format = get_format_from_list (dialog->list);
|
sel_format = get_format_from_list (conf_widget->list);
|
||||||
set_selected_format (dialog->settings, formats[sel_format]);
|
g_settings_set_string (conf_widget->settings, SELECTED_FORMAT_KEY, formats[sel_format]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static TimeConfigureDialog *
|
static TimeConfigureWidget *
|
||||||
get_configure_dialog (XedTimePlugin *plugin)
|
get_configure_widget (XedTimePlugin *plugin)
|
||||||
{
|
{
|
||||||
TimeConfigureDialog *dialog = NULL;
|
TimeConfigureWidget *widget = NULL;
|
||||||
GtkTreeSelection *selection;
|
GtkTreeSelection *selection;
|
||||||
gchar *data_dir;
|
gchar *data_dir;
|
||||||
gchar *ui_file;
|
gchar *ui_file;
|
||||||
GtkWidget *content;
|
|
||||||
GtkWidget *viewport;
|
GtkWidget *viewport;
|
||||||
XedTimePluginPromptType prompt_type;
|
XedTimePluginPromptType prompt_type;
|
||||||
gchar *sf, *cf;
|
gchar *sf;
|
||||||
GtkWidget *error_widget;
|
GtkWidget *error_widget;
|
||||||
gboolean ret;
|
gboolean ret;
|
||||||
gchar *root_objects[] = {
|
gchar *root_objects[] = {
|
||||||
|
@ -744,22 +702,22 @@ get_configure_dialog (XedTimePlugin *plugin)
|
||||||
|
|
||||||
xed_debug (DEBUG_PLUGINS);
|
xed_debug (DEBUG_PLUGINS);
|
||||||
|
|
||||||
dialog = g_slice_new (TimeConfigureDialog);
|
widget = g_slice_new (TimeConfigureWidget);
|
||||||
dialog->settings = g_object_ref (plugin->priv->settings);
|
widget->settings = g_object_ref (plugin->priv->settings);
|
||||||
|
|
||||||
data_dir = peas_extension_base_get_data_dir (PEAS_EXTENSION_BASE (plugin));
|
data_dir = peas_extension_base_get_data_dir (PEAS_EXTENSION_BASE (plugin));
|
||||||
ui_file = g_build_filename (data_dir, "xed-time-setup-dialog.ui", NULL);
|
ui_file = g_build_filename (data_dir, "xed-time-setup-dialog.ui", NULL);
|
||||||
ret = xed_utils_get_ui_objects (ui_file,
|
ret = xed_utils_get_ui_objects (ui_file,
|
||||||
root_objects,
|
root_objects,
|
||||||
&error_widget,
|
&error_widget,
|
||||||
"time_dialog_content", &dialog->content,
|
"time_dialog_content", &widget->content,
|
||||||
"formats_viewport", &viewport,
|
"formats_viewport", &viewport,
|
||||||
"formats_tree", &dialog->list,
|
"formats_tree", &widget->list,
|
||||||
"always_prompt", &dialog->prompt,
|
"always_prompt", &widget->prompt,
|
||||||
"never_prompt", &dialog->use_list,
|
"never_prompt", &widget->use_list,
|
||||||
"use_custom", &dialog->custom,
|
"use_custom", &widget->custom,
|
||||||
"custom_entry", &dialog->custom_entry,
|
"custom_entry", &widget->custom_entry,
|
||||||
"custom_format_example", &dialog->custom_format_example,
|
"custom_format_example", &widget->custom_format_example,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
g_free (data_dir);
|
g_free (data_dir);
|
||||||
|
@ -771,56 +729,61 @@ get_configure_dialog (XedTimePlugin *plugin)
|
||||||
}
|
}
|
||||||
|
|
||||||
sf = get_selected_format (plugin);
|
sf = get_selected_format (plugin);
|
||||||
create_formats_list (dialog->list, sf, plugin);
|
create_formats_list (widget->list, sf, plugin);
|
||||||
g_free (sf);
|
g_free (sf);
|
||||||
|
|
||||||
prompt_type = get_prompt_type (plugin);
|
prompt_type = g_settings_get_enum (plugin->priv->settings, PROMPT_TYPE_KEY);
|
||||||
|
|
||||||
g_settings_bind (dialog->settings, CUSTOM_FORMAT_KEY,
|
g_settings_bind (widget->settings, CUSTOM_FORMAT_KEY,
|
||||||
dialog->custom_entry, "text",
|
widget->custom_entry, "text",
|
||||||
G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
|
G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
|
||||||
|
|
||||||
if (prompt_type == USE_CUSTOM_FORMAT)
|
if (prompt_type == USE_CUSTOM_FORMAT)
|
||||||
{
|
{
|
||||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->custom), TRUE);
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget->custom), TRUE);
|
||||||
|
|
||||||
gtk_widget_set_sensitive (dialog->list, FALSE);
|
gtk_widget_set_sensitive (widget->list, FALSE);
|
||||||
gtk_widget_set_sensitive (dialog->custom_entry, TRUE);
|
gtk_widget_set_sensitive (widget->custom_entry, TRUE);
|
||||||
gtk_widget_set_sensitive (dialog->custom_format_example, TRUE);
|
gtk_widget_set_sensitive (widget->custom_format_example, TRUE);
|
||||||
}
|
}
|
||||||
else if (prompt_type == USE_SELECTED_FORMAT)
|
else if (prompt_type == USE_SELECTED_FORMAT)
|
||||||
{
|
{
|
||||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->use_list), TRUE);
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget->use_list), TRUE);
|
||||||
|
|
||||||
gtk_widget_set_sensitive (dialog->list, TRUE);
|
gtk_widget_set_sensitive (widget->list, TRUE);
|
||||||
gtk_widget_set_sensitive (dialog->custom_entry, FALSE);
|
gtk_widget_set_sensitive (widget->custom_entry, FALSE);
|
||||||
gtk_widget_set_sensitive (dialog->custom_format_example, FALSE);
|
gtk_widget_set_sensitive (widget->custom_format_example, FALSE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->prompt), TRUE);
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget->prompt), TRUE);
|
||||||
|
|
||||||
gtk_widget_set_sensitive (dialog->list, FALSE);
|
gtk_widget_set_sensitive (widget->list, FALSE);
|
||||||
gtk_widget_set_sensitive (dialog->custom_entry, FALSE);
|
gtk_widget_set_sensitive (widget->custom_entry, FALSE);
|
||||||
gtk_widget_set_sensitive (dialog->custom_format_example, FALSE);
|
gtk_widget_set_sensitive (widget->custom_format_example, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
updated_custom_format_example (GTK_ENTRY (dialog->custom_entry),
|
updated_custom_format_example (GTK_ENTRY (widget->custom_entry), GTK_LABEL (widget->custom_format_example));
|
||||||
GTK_LABEL (dialog->custom_format_example));
|
|
||||||
|
|
||||||
/* setup a window of a sane size. */
|
/* setup a window of a sane size. */
|
||||||
gtk_widget_set_size_request (GTK_WIDGET (viewport), 10, 200);
|
gtk_widget_set_size_request (GTK_WIDGET (viewport), 10, 200);
|
||||||
|
|
||||||
g_signal_connect (dialog->custom, "toggled", G_CALLBACK (configure_dialog_button_toggled), dialog);
|
g_signal_connect (widget->custom, "toggled",
|
||||||
g_signal_connect (dialog->prompt, "toggled", G_CALLBACK (configure_dialog_button_toggled), dialog);
|
G_CALLBACK (configure_widget_button_toggled), widget);
|
||||||
g_signal_connect (dialog->use_list, "toggled", G_CALLBACK (configure_dialog_button_toggled), dialog);
|
g_signal_connect (widget->prompt, "toggled",
|
||||||
g_signal_connect (dialog->content, "destroy", G_CALLBACK (configure_dialog_destroyed), dialog);
|
G_CALLBACK (configure_widget_button_toggled), widget);
|
||||||
g_signal_connect (dialog->custom_entry, "changed", G_CALLBACK (updated_custom_format_example), dialog->custom_format_example);
|
g_signal_connect (widget->use_list, "toggled",
|
||||||
|
G_CALLBACK (configure_widget_button_toggled), widget);
|
||||||
|
g_signal_connect (widget->content, "destroy",
|
||||||
|
G_CALLBACK (configure_widget_destroyed), widget);
|
||||||
|
g_signal_connect (widget->custom_entry, "changed",
|
||||||
|
G_CALLBACK (updated_custom_format_example), widget->custom_format_example);
|
||||||
|
|
||||||
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->list));
|
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (widget->list));
|
||||||
g_signal_connect (selection, "changed", G_CALLBACK (configure_dialog_selection_changed), dialog);
|
g_signal_connect (selection, "changed",
|
||||||
|
G_CALLBACK (on_configure_widget_selection_changed), widget);
|
||||||
|
|
||||||
return dialog;
|
return widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -849,8 +812,8 @@ choose_format_dialog_row_activated (GtkTreeView *list,
|
||||||
sel_format = get_format_from_list (dialog->list);
|
sel_format = get_format_from_list (dialog->list);
|
||||||
the_time = get_time (formats[sel_format]);
|
the_time = get_time (formats[sel_format]);
|
||||||
|
|
||||||
set_prompt_type (dialog->settings, PROMPT_SELECTED_FORMAT);
|
g_settings_set_enum (dialog->settings, PROMPT_TYPE_KEY, PROMPT_SELECTED_FORMAT);
|
||||||
set_selected_format (dialog->settings, formats[sel_format]);
|
g_settings_set_string (dialog->settings, SELECTED_FORMAT_KEY, formats[sel_format]);
|
||||||
|
|
||||||
g_return_if_fail (the_time != NULL);
|
g_return_if_fail (the_time != NULL);
|
||||||
|
|
||||||
|
@ -873,7 +836,9 @@ get_choose_format_dialog (GtkWindow *parent,
|
||||||
GtkWindowGroup *wg = NULL;
|
GtkWindowGroup *wg = NULL;
|
||||||
|
|
||||||
if (parent != NULL)
|
if (parent != NULL)
|
||||||
|
{
|
||||||
wg = gtk_window_get_group (parent);
|
wg = gtk_window_get_group (parent);
|
||||||
|
}
|
||||||
|
|
||||||
dialog = g_slice_new (ChooseFormatDialog);
|
dialog = g_slice_new (ChooseFormatDialog);
|
||||||
dialog->settings = plugin->priv->settings;
|
dialog->settings = plugin->priv->settings;
|
||||||
|
@ -905,26 +870,24 @@ get_choose_format_dialog (GtkWindow *parent,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
if (wg != NULL)
|
if (wg != NULL)
|
||||||
|
{
|
||||||
gtk_window_group_add_window (wg, GTK_WINDOW (err_dialog));
|
gtk_window_group_add_window (wg, GTK_WINDOW (err_dialog));
|
||||||
|
}
|
||||||
|
|
||||||
gtk_window_set_resizable (GTK_WINDOW (err_dialog), FALSE);
|
gtk_window_set_resizable (GTK_WINDOW (err_dialog), FALSE);
|
||||||
gtk_dialog_set_default_response (GTK_DIALOG (err_dialog), GTK_RESPONSE_OK);
|
gtk_dialog_set_default_response (GTK_DIALOG (err_dialog), GTK_RESPONSE_OK);
|
||||||
|
|
||||||
gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (err_dialog))),
|
gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (err_dialog))), error_widget);
|
||||||
error_widget);
|
|
||||||
|
|
||||||
g_signal_connect (G_OBJECT (err_dialog),
|
g_signal_connect (G_OBJECT (err_dialog), "response",
|
||||||
"response",
|
G_CALLBACK (gtk_widget_destroy), NULL);
|
||||||
G_CALLBACK (gtk_widget_destroy),
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
gtk_widget_show_all (err_dialog);
|
gtk_widget_show_all (err_dialog);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_window_group_add_window (wg,
|
gtk_window_group_add_window (wg, GTK_WINDOW (dialog->dialog));
|
||||||
GTK_WINDOW (dialog->dialog));
|
|
||||||
gtk_window_set_transient_for (GTK_WINDOW (dialog->dialog), parent);
|
gtk_window_set_transient_for (GTK_WINDOW (dialog->dialog), parent);
|
||||||
gtk_window_set_modal (GTK_WINDOW (dialog->dialog), TRUE);
|
gtk_window_set_modal (GTK_WINDOW (dialog->dialog), TRUE);
|
||||||
|
|
||||||
|
@ -963,29 +926,18 @@ get_choose_format_dialog (GtkWindow *parent,
|
||||||
/* setup a window of a sane size. */
|
/* setup a window of a sane size. */
|
||||||
gtk_widget_set_size_request (dialog->list, 10, 200);
|
gtk_widget_set_size_request (dialog->list, 10, 200);
|
||||||
|
|
||||||
gtk_dialog_set_default_response (GTK_DIALOG (dialog->dialog),
|
gtk_dialog_set_default_response (GTK_DIALOG (dialog->dialog), GTK_RESPONSE_OK);
|
||||||
GTK_RESPONSE_OK);
|
|
||||||
|
|
||||||
g_signal_connect (dialog->custom,
|
g_signal_connect (dialog->custom, "toggled",
|
||||||
"toggled",
|
G_CALLBACK (choose_format_dialog_button_toggled), dialog);
|
||||||
G_CALLBACK (choose_format_dialog_button_toggled),
|
g_signal_connect (dialog->use_list, "toggled",
|
||||||
dialog);
|
G_CALLBACK (choose_format_dialog_button_toggled), dialog);
|
||||||
g_signal_connect (dialog->use_list,
|
g_signal_connect (dialog->dialog, "destroy",
|
||||||
"toggled",
|
G_CALLBACK (choose_format_dialog_destroyed), dialog);
|
||||||
G_CALLBACK (choose_format_dialog_button_toggled),
|
g_signal_connect (dialog->custom_entry, "changed",
|
||||||
dialog);
|
G_CALLBACK (updated_custom_format_example), dialog->custom_format_example);
|
||||||
g_signal_connect (dialog->dialog,
|
g_signal_connect (dialog->list, "row_activated",
|
||||||
"destroy",
|
G_CALLBACK (choose_format_dialog_row_activated), dialog);
|
||||||
G_CALLBACK (choose_format_dialog_destroyed),
|
|
||||||
dialog);
|
|
||||||
g_signal_connect (dialog->custom_entry,
|
|
||||||
"changed",
|
|
||||||
G_CALLBACK (updated_custom_format_example),
|
|
||||||
dialog->custom_format_example);
|
|
||||||
g_signal_connect (dialog->list,
|
|
||||||
"row_activated",
|
|
||||||
G_CALLBACK (choose_format_dialog_row_activated),
|
|
||||||
dialog);
|
|
||||||
|
|
||||||
gtk_window_set_resizable (GTK_WINDOW (dialog->dialog), FALSE);
|
gtk_window_set_resizable (GTK_WINDOW (dialog->dialog), FALSE);
|
||||||
|
|
||||||
|
@ -1002,9 +954,7 @@ choose_format_dialog_response_cb (GtkWidget *widget,
|
||||||
case GTK_RESPONSE_HELP:
|
case GTK_RESPONSE_HELP:
|
||||||
{
|
{
|
||||||
xed_debug_message (DEBUG_PLUGINS, "GTK_RESPONSE_HELP");
|
xed_debug_message (DEBUG_PLUGINS, "GTK_RESPONSE_HELP");
|
||||||
xed_help_display (GTK_WINDOW (widget),
|
xed_help_display (GTK_WINDOW (widget), NULL, "xed-insert-date-time-plugin");
|
||||||
NULL,
|
|
||||||
"xed-insert-date-time-plugin");
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case GTK_RESPONSE_OK:
|
case GTK_RESPONSE_OK:
|
||||||
|
@ -1021,8 +971,8 @@ choose_format_dialog_response_cb (GtkWidget *widget,
|
||||||
sel_format = get_format_from_list (dialog->list);
|
sel_format = get_format_from_list (dialog->list);
|
||||||
the_time = get_time (formats[sel_format]);
|
the_time = get_time (formats[sel_format]);
|
||||||
|
|
||||||
set_prompt_type (dialog->settings, PROMPT_SELECTED_FORMAT);
|
g_settings_set_enum (dialog->settings, PROMPT_TYPE_KEY, PROMPT_SELECTED_FORMAT);
|
||||||
set_selected_format (dialog->settings, formats[sel_format]);
|
g_settings_set_string (dialog->settings, SELECTED_FORMAT_KEY, formats[sel_format]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1031,8 +981,8 @@ choose_format_dialog_response_cb (GtkWidget *widget,
|
||||||
format = gtk_entry_get_text (GTK_ENTRY (dialog->custom_entry));
|
format = gtk_entry_get_text (GTK_ENTRY (dialog->custom_entry));
|
||||||
the_time = get_time (format);
|
the_time = get_time (format);
|
||||||
|
|
||||||
set_prompt_type (dialog->settings, PROMPT_CUSTOM_FORMAT);
|
g_settings_set_enum (dialog->settings, PROMPT_TYPE_KEY, PROMPT_CUSTOM_FORMAT);
|
||||||
set_custom_format (dialog->settings, format);
|
g_settings_set_string (dialog->settings, CUSTOM_FORMAT_KEY, format);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_return_if_fail (the_time != NULL);
|
g_return_if_fail (the_time != NULL);
|
||||||
|
@ -1053,18 +1003,19 @@ static void
|
||||||
time_cb (GtkAction *action,
|
time_cb (GtkAction *action,
|
||||||
XedTimePlugin *plugin)
|
XedTimePlugin *plugin)
|
||||||
{
|
{
|
||||||
XedWindow *window;
|
XedTimePluginPrivate *priv;
|
||||||
GtkTextBuffer *buffer;
|
GtkTextBuffer *buffer;
|
||||||
gchar *the_time = NULL;
|
gchar *the_time = NULL;
|
||||||
XedTimePluginPromptType prompt_type;
|
XedTimePluginPromptType prompt_type;
|
||||||
|
|
||||||
xed_debug (DEBUG_PLUGINS);
|
xed_debug (DEBUG_PLUGINS);
|
||||||
|
|
||||||
window = XED_WINDOW (plugin->priv->window);
|
priv = plugin->priv;
|
||||||
buffer = GTK_TEXT_BUFFER (xed_window_get_active_document (window));
|
|
||||||
|
buffer = GTK_TEXT_BUFFER (xed_window_get_active_document (priv->window));
|
||||||
g_return_if_fail (buffer != NULL);
|
g_return_if_fail (buffer != NULL);
|
||||||
|
|
||||||
prompt_type = get_prompt_type (plugin);
|
prompt_type = g_settings_get_enum (plugin->priv->settings, PROMPT_TYPE_KEY);
|
||||||
|
|
||||||
if (prompt_type == USE_CUSTOM_FORMAT)
|
if (prompt_type == USE_CUSTOM_FORMAT)
|
||||||
{
|
{
|
||||||
|
@ -1082,18 +1033,14 @@ time_cb (GtkAction *action,
|
||||||
{
|
{
|
||||||
ChooseFormatDialog *dialog;
|
ChooseFormatDialog *dialog;
|
||||||
|
|
||||||
dialog = get_choose_format_dialog (GTK_WINDOW (window),
|
dialog = get_choose_format_dialog (GTK_WINDOW (priv->window), prompt_type, plugin);
|
||||||
prompt_type,
|
|
||||||
plugin);
|
|
||||||
if (dialog != NULL)
|
if (dialog != NULL)
|
||||||
{
|
{
|
||||||
dialog->buffer = buffer;
|
dialog->buffer = buffer;
|
||||||
dialog->settings = plugin->priv->settings;
|
dialog->settings = priv->settings;
|
||||||
|
|
||||||
g_signal_connect (dialog->dialog,
|
g_signal_connect (dialog->dialog, "response",
|
||||||
"response",
|
G_CALLBACK (choose_format_dialog_response_cb), dialog);
|
||||||
G_CALLBACK (choose_format_dialog_response_cb),
|
|
||||||
dialog);
|
|
||||||
|
|
||||||
gtk_widget_show (GTK_WIDGET (dialog->dialog));
|
gtk_widget_show (GTK_WIDGET (dialog->dialog));
|
||||||
}
|
}
|
||||||
|
@ -1111,11 +1058,11 @@ time_cb (GtkAction *action,
|
||||||
static GtkWidget *
|
static GtkWidget *
|
||||||
xed_time_plugin_create_configure_widget (PeasGtkConfigurable *configurable)
|
xed_time_plugin_create_configure_widget (PeasGtkConfigurable *configurable)
|
||||||
{
|
{
|
||||||
TimeConfigureDialog *dialog;
|
TimeConfigureWidget *widget;
|
||||||
|
|
||||||
dialog = get_configure_dialog (XED_TIME_PLUGIN (configurable));
|
widget = get_configure_widget (XED_TIME_PLUGIN (configurable));
|
||||||
|
|
||||||
return dialog->content;
|
return widget->content;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -1128,8 +1075,8 @@ xed_time_plugin_set_property (GObject *object,
|
||||||
|
|
||||||
switch (prop_id)
|
switch (prop_id)
|
||||||
{
|
{
|
||||||
case PROP_OBJECT:
|
case PROP_WINDOW:
|
||||||
plugin->priv->window = GTK_WIDGET (g_value_dup_object (value));
|
plugin->priv->window = XED_WINDOW (g_value_dup_object (value));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
@ -1147,7 +1094,7 @@ xed_time_plugin_get_property (GObject *object,
|
||||||
|
|
||||||
switch (prop_id)
|
switch (prop_id)
|
||||||
{
|
{
|
||||||
case PROP_OBJECT:
|
case PROP_WINDOW:
|
||||||
g_value_set_object (value, plugin->priv->window);
|
g_value_set_object (value, plugin->priv->window);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -1166,7 +1113,7 @@ xed_time_plugin_class_init (XedTimePluginClass *klass)
|
||||||
object_class->set_property = xed_time_plugin_set_property;
|
object_class->set_property = xed_time_plugin_set_property;
|
||||||
object_class->get_property = xed_time_plugin_get_property;
|
object_class->get_property = xed_time_plugin_get_property;
|
||||||
|
|
||||||
g_object_class_override_property (object_class, PROP_OBJECT, "object");
|
g_object_class_override_property (object_class, PROP_WINDOW, "window");
|
||||||
|
|
||||||
g_type_class_add_private (object_class, sizeof (XedTimePluginPrivate));
|
g_type_class_add_private (object_class, sizeof (XedTimePluginPrivate));
|
||||||
}
|
}
|
||||||
|
@ -1178,7 +1125,7 @@ xed_time_plugin_class_finalize (XedTimePluginClass *klass)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
peas_activatable_iface_init (PeasActivatableInterface *iface)
|
xed_window_activatable_iface_init (XedWindowActivatableInterface *iface)
|
||||||
{
|
{
|
||||||
iface->activate = xed_time_plugin_activate;
|
iface->activate = xed_time_plugin_activate;
|
||||||
iface->deactivate = xed_time_plugin_deactivate;
|
iface->deactivate = xed_time_plugin_deactivate;
|
||||||
|
@ -1197,7 +1144,7 @@ peas_register_types (PeasObjectModule *module)
|
||||||
xed_time_plugin_register_type (G_TYPE_MODULE (module));
|
xed_time_plugin_register_type (G_TYPE_MODULE (module));
|
||||||
|
|
||||||
peas_object_module_register_extension_type (module,
|
peas_object_module_register_extension_type (module,
|
||||||
PEAS_TYPE_ACTIVATABLE,
|
XED_TYPE_WINDOW_ACTIVATABLE,
|
||||||
XED_TYPE_TIME_PLUGIN);
|
XED_TYPE_TIME_PLUGIN);
|
||||||
|
|
||||||
peas_object_module_register_extension_type (module,
|
peas_object_module_register_extension_type (module,
|
||||||
|
|
|
@ -30,9 +30,6 @@
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
/*
|
|
||||||
* Type checking and casting macros
|
|
||||||
*/
|
|
||||||
#define XED_TYPE_TIME_PLUGIN (xed_time_plugin_get_type ())
|
#define XED_TYPE_TIME_PLUGIN (xed_time_plugin_get_type ())
|
||||||
#define XED_TIME_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), XED_TYPE_TIME_PLUGIN, XedTimePlugin))
|
#define XED_TIME_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), XED_TYPE_TIME_PLUGIN, XedTimePlugin))
|
||||||
#define XED_TIME_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), XED_TYPE_TIME_PLUGIN, XedTimePluginClass))
|
#define XED_TIME_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), XED_TYPE_TIME_PLUGIN, XedTimePluginClass))
|
||||||
|
@ -40,13 +37,9 @@ G_BEGIN_DECLS
|
||||||
#define XED_IS_TIME_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), XED_TYPE_TIME_PLUGIN))
|
#define XED_IS_TIME_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), XED_TYPE_TIME_PLUGIN))
|
||||||
#define XED_TIME_PLUGIN_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), XED_TYPE_TIME_PLUGIN, XedTimePluginClass))
|
#define XED_TIME_PLUGIN_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), XED_TYPE_TIME_PLUGIN, XedTimePluginClass))
|
||||||
|
|
||||||
/* Private structure type */
|
|
||||||
typedef struct _XedTimePluginPrivate XedTimePluginPrivate;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Main object structure
|
|
||||||
*/
|
|
||||||
typedef struct _XedTimePlugin XedTimePlugin;
|
typedef struct _XedTimePlugin XedTimePlugin;
|
||||||
|
typedef struct _XedTimePluginPrivate XedTimePluginPrivate;
|
||||||
|
typedef struct _XedTimePluginClass XedTimePluginClass;
|
||||||
|
|
||||||
struct _XedTimePlugin
|
struct _XedTimePlugin
|
||||||
{
|
{
|
||||||
|
@ -56,19 +49,11 @@ struct _XedTimePlugin
|
||||||
XedTimePluginPrivate *priv;
|
XedTimePluginPrivate *priv;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
|
||||||
* Class definition
|
|
||||||
*/
|
|
||||||
typedef struct _XedTimePluginClass XedTimePluginClass;
|
|
||||||
|
|
||||||
struct _XedTimePluginClass
|
struct _XedTimePluginClass
|
||||||
{
|
{
|
||||||
PeasExtensionBaseClass parent_class;
|
PeasExtensionBaseClass parent_class;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
|
||||||
* Public methods
|
|
||||||
*/
|
|
||||||
GType xed_time_plugin_get_type (void) G_GNUC_CONST;
|
GType xed_time_plugin_get_type (void) G_GNUC_CONST;
|
||||||
|
|
||||||
/* All the plugins must implement this function */
|
/* All the plugins must implement this function */
|
||||||
|
|
Loading…
Reference in New Issue