Skip to content

Commit 997f405

Browse files
committed
actions: Refactor to remove unnecessary methods.
Actions get re-created any time they change, so there are never any previous values of properties that need to be freed/
1 parent e19187d commit 997f405

File tree

1 file changed

+16
-157
lines changed

1 file changed

+16
-157
lines changed

libnemo-private/nemo-action.c

Lines changed: 16 additions & 157 deletions
Original file line numberDiff line numberDiff line change
@@ -47,20 +47,6 @@ static void nemo_action_set_property (GObject *object,
4747
static void nemo_action_constructed (GObject *object);
4848
static void nemo_action_finalize (GObject *gobject);
4949

50-
static SelectionType nemo_action_get_selection_type (NemoAction *action);
51-
static void nemo_action_set_extensions (NemoAction *action, gchar **extensions);
52-
static gchar **nemo_action_get_extension_list (NemoAction *action);
53-
static void nemo_action_set_mimetypes (NemoAction *action, gchar **mimetypes);
54-
static gchar **nemo_action_get_mimetypes_list (NemoAction *action);
55-
static void nemo_action_set_key_file_path (NemoAction *action, const gchar *path);
56-
static void nemo_action_set_exec (NemoAction *action, const gchar *exec);
57-
static void nemo_action_set_parent_dir (NemoAction *action, const gchar *parent_dir);
58-
static void nemo_action_set_separator (NemoAction *action, const gchar *separator);
59-
static void nemo_action_set_conditions (NemoAction *action, gchar **conditions);
60-
static gchar **nemo_action_get_conditions (NemoAction *action);
61-
static void nemo_action_set_orig_label (NemoAction *action, const gchar *orig_label);
62-
static void nemo_action_set_orig_tt (NemoAction *action, const gchar *orig_tt);
63-
6450
static gchar *find_token_type (const gchar *str, TokenType *token_type);
6551

6652
static gpointer parent_class;
@@ -1033,40 +1019,40 @@ nemo_action_set_property (GObject *object,
10331019
switch (prop_id)
10341020
{
10351021
case PROP_KEY_FILE_PATH:
1036-
nemo_action_set_key_file_path (action, g_value_get_string (value));
1022+
action->key_file_path = g_strdup (g_value_get_string (value));
10371023
break;
10381024
case PROP_SELECTION_TYPE:
10391025
action->selection_type = g_value_get_int (value);
10401026
break;
10411027
case PROP_EXTENSIONS:
1042-
nemo_action_set_extensions (action, g_value_get_pointer (value));
1028+
action->extensions = g_strdupv (g_value_get_pointer (value));
10431029
break;
10441030
case PROP_MIMES:
1045-
nemo_action_set_mimetypes (action, g_value_get_pointer (value));
1031+
action->mimetypes = g_strdupv (g_value_get_pointer (value));
10461032
break;
10471033
case PROP_EXEC:
1048-
nemo_action_set_exec (action, g_value_get_string (value));
1034+
action->exec = g_strdup (g_value_get_string (value));
10491035
break;
10501036
case PROP_PARENT_DIR:
1051-
nemo_action_set_parent_dir (action, g_value_get_string (value));
1037+
action->parent_dir = g_strdup (g_value_get_string (value));
10521038
break;
10531039
case PROP_USE_PARENT_DIR:
10541040
action->use_parent_dir = g_value_get_boolean (value);
10551041
break;
10561042
case PROP_ORIG_LABEL:
1057-
nemo_action_set_orig_label (action, g_value_get_string (value));
1043+
action->orig_label = g_strdup (g_value_get_string (value));
10581044
break;
10591045
case PROP_ORIG_TT:
1060-
nemo_action_set_orig_tt (action, g_value_get_string (value));
1046+
action->orig_tt = g_strdup (g_value_get_string (value));
10611047
break;
10621048
case PROP_QUOTE_TYPE:
10631049
action->quote_type = g_value_get_int (value);
10641050
break;
10651051
case PROP_SEPARATOR:
1066-
nemo_action_set_separator (action, g_value_get_string (value));
1052+
action->separator = g_strdup (g_value_get_string (value));
10671053
break;
10681054
case PROP_CONDITIONS:
1069-
nemo_action_set_conditions (action, g_value_get_pointer (value));
1055+
action->conditions = g_strdupv (g_value_get_pointer (value));
10701056
break;
10711057
case PROP_ESCAPE_SPACE:
10721058
action->escape_space = g_value_get_boolean (value);
@@ -1503,119 +1489,6 @@ nemo_action_activate (NemoAction *action,
15031489
g_string_free (exec, TRUE);
15041490
}
15051491

1506-
static SelectionType
1507-
nemo_action_get_selection_type (NemoAction *action)
1508-
{
1509-
return action->selection_type;
1510-
}
1511-
1512-
static void
1513-
nemo_action_set_extensions (NemoAction *action, gchar **extensions)
1514-
{
1515-
gchar **tmp;
1516-
1517-
tmp = action->extensions;
1518-
action->extensions = g_strdupv (extensions);
1519-
g_strfreev (tmp);
1520-
}
1521-
1522-
static gchar **
1523-
nemo_action_get_extension_list (NemoAction *action)
1524-
{
1525-
return action->extensions;
1526-
}
1527-
1528-
static void
1529-
nemo_action_set_mimetypes (NemoAction *action, gchar **mimetypes)
1530-
{
1531-
gchar **tmp;
1532-
1533-
tmp = action->mimetypes;
1534-
action->mimetypes = g_strdupv (mimetypes);
1535-
g_strfreev (tmp);
1536-
}
1537-
1538-
static gchar **
1539-
nemo_action_get_mimetypes_list (NemoAction *action)
1540-
{
1541-
return action->mimetypes;
1542-
}
1543-
1544-
static void
1545-
nemo_action_set_key_file_path (NemoAction *action, const gchar *path)
1546-
{
1547-
gchar *tmp;
1548-
tmp = action->key_file_path;
1549-
action->key_file_path = g_strdup (path);
1550-
g_free (tmp);
1551-
}
1552-
1553-
static void
1554-
nemo_action_set_exec (NemoAction *action, const gchar *exec)
1555-
{
1556-
gchar *tmp;
1557-
1558-
tmp = action->exec;
1559-
action->exec = g_strdup (exec);
1560-
g_free (tmp);
1561-
}
1562-
1563-
static void
1564-
nemo_action_set_parent_dir (NemoAction *action, const gchar *parent_dir)
1565-
{
1566-
gchar *tmp;
1567-
1568-
tmp = action->parent_dir;
1569-
action->parent_dir = g_strdup (parent_dir);
1570-
g_free (tmp);
1571-
}
1572-
1573-
static void
1574-
nemo_action_set_separator (NemoAction *action, const gchar *separator)
1575-
{
1576-
gchar *tmp;
1577-
1578-
tmp = action->separator;
1579-
action->separator = g_strdup (separator);
1580-
g_free (tmp);
1581-
}
1582-
1583-
static void
1584-
nemo_action_set_conditions (NemoAction *action, gchar **conditions)
1585-
{
1586-
gchar **tmp;
1587-
1588-
tmp = action->conditions;
1589-
action->conditions = g_strdupv (conditions);
1590-
g_strfreev (tmp);
1591-
}
1592-
1593-
static gchar **
1594-
nemo_action_get_conditions (NemoAction *action)
1595-
{
1596-
return action->conditions;
1597-
}
1598-
1599-
static void
1600-
nemo_action_set_orig_label (NemoAction *action, const gchar *orig_label)
1601-
{
1602-
gchar *tmp;
1603-
1604-
tmp = action->orig_label;
1605-
action->orig_label = g_strdup (orig_label);
1606-
g_free (tmp);
1607-
}
1608-
1609-
static void
1610-
nemo_action_set_orig_tt (NemoAction *action, const gchar *orig_tt)
1611-
{
1612-
gchar *tmp;
1613-
1614-
tmp = action->orig_tt;
1615-
action->orig_tt = g_strdup (orig_tt);
1616-
g_free (tmp);
1617-
}
1618-
16191492
const gchar *
16201493
nemo_action_get_orig_label (NemoAction *action)
16211494
{
@@ -1677,18 +1550,6 @@ nemo_action_get_tt (NemoAction *action,
16771550
return ret;
16781551
}
16791552

1680-
static gboolean
1681-
get_dbus_satisfied (NemoAction *action)
1682-
{
1683-
return action->dbus_satisfied;
1684-
}
1685-
1686-
static gboolean
1687-
get_gsettings_satisfied (NemoAction *action)
1688-
{
1689-
return action->gsettings_satisfied;
1690-
}
1691-
16921553
static gboolean
16931554
check_exec_condition (NemoAction *action,
16941555
const gchar *condition,
@@ -1783,19 +1644,17 @@ nemo_action_get_visibility (NemoAction *action,
17831644
GtkWindow *window)
17841645
{
17851646
// Check DBUS
1786-
if (!get_dbus_satisfied (action))
1647+
if (!action->dbus_satisfied)
17871648
return FALSE;
17881649

1789-
if (!get_gsettings_satisfied (action))
1650+
if (!action->gsettings_satisfied)
17901651
return FALSE;
17911652

17921653
// Check selection
17931654
gboolean selection_type_show = FALSE;
1794-
SelectionType selection_type = nemo_action_get_selection_type (action);
1795-
17961655
guint selected_count = g_list_length (selection);
17971656

1798-
switch (selection_type) {
1657+
switch (action->selection_type) {
17991658
case SELECTION_SINGLE:
18001659
selection_type_show = selected_count == 1;
18011660
break;
@@ -1812,7 +1671,7 @@ nemo_action_get_visibility (NemoAction *action,
18121671
selection_type_show = TRUE;
18131672
break;
18141673
default:
1815-
selection_type_show = selected_count == selection_type;
1674+
selection_type_show = selected_count == action->selection_type;
18161675
break;
18171676
}
18181677

@@ -1821,8 +1680,8 @@ nemo_action_get_visibility (NemoAction *action,
18211680

18221681
// Check extensions and mimetypes
18231682
gboolean extension_type_show = TRUE;
1824-
gchar **extensions = nemo_action_get_extension_list (action);
1825-
gchar **mimetypes = nemo_action_get_mimetypes_list (action);
1683+
gchar **extensions = action->extensions;
1684+
gchar **mimetypes = action->mimetypes;
18261685

18271686
guint ext_count = extensions != NULL ? g_strv_length (extensions) : 0;
18281687
guint mime_count = mimetypes != NULL ? g_strv_length (mimetypes) : 0;
@@ -1897,7 +1756,7 @@ nemo_action_get_visibility (NemoAction *action,
18971756

18981757
// Check conditions
18991758
gboolean condition_type_show = TRUE;
1900-
gchar **conditions = nemo_action_get_conditions (action);
1759+
gchar **conditions = action->conditions;
19011760
guint condition_count = conditions != NULL ? g_strv_length (conditions) : 0;
19021761

19031762
if (condition_count > 0) {

0 commit comments

Comments
 (0)