Commit 313ada99 authored by Victor Ananjevsky's avatar Victor Ananjevsky

code cleanup

parent 8e2035ec
......@@ -43,14 +43,14 @@ parse_details ()
/* read details file */
while (!feof (f))
{
gchar buf[4096], **dtl;
gchar buf[4096];
/* read string */
memset (buf, 0, 4096);
fgets (buf, 4096, f);
if (strlen (buf) > 0)
{
dtl = g_strsplit (buf, " ", 2);
gchar **dtl = g_strsplit (buf, " ", 2);
g_hash_table_insert (details, dtl[0], dtl[1]);
}
}
......@@ -75,7 +75,8 @@ get_details (GtkCalendar * cal, guint year, guint month, guint day, gpointer dat
if (str)
return g_strdup (str);
return str;
return NULL;
}
static void
......
......@@ -169,7 +169,7 @@ expand_action (gchar * cmd)
}
static void
set_field_value (guint num, gchar * value)
set_field_value (guint num, gchar *value)
{
GtkWidget *w;
gchar **s;
......@@ -370,7 +370,7 @@ set_field_value (guint num, gchar * value)
}
static void
button_clicked_cb (GtkButton * b, gpointer data)
button_clicked_cb (GtkButton * b, gpointer d)
{
gchar *action = (gchar *) g_object_get_data (G_OBJECT (b), "cmd");
......@@ -1157,7 +1157,7 @@ form_create_widget (GtkWidget * dlg)
case YAD_FIELD_TEXT:
{
GtkWidget *l, *sw, *b;
GtkWidget *sw, *b;
gchar *ltxt;
if (fld->name)
......@@ -1440,7 +1440,7 @@ form_print_result (void)
guint j, rows;
rows = n_fields / options.form_data.columns;
rows += (n_fields % options.form_data.columns ? 1 : 0);
rows += ((n_fields % options.form_data.columns) ? 1 : 0);
for (i = 0; i < rows; i++)
{
for (j = 0; j < options.form_data.columns; j++)
......
......@@ -320,7 +320,7 @@ GtkWidget *
html_create_widget (GtkWidget * dlg)
{
GtkWidget *sw;
WebKitSettings *settings;
WebKitSettings *wk_settings;
sw = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), options.hscroll_policy, options.vscroll_policy);
......@@ -328,17 +328,17 @@ html_create_widget (GtkWidget * dlg)
view = WEBKIT_WEB_VIEW (webkit_web_view_new ());
gtk_container_add (GTK_CONTAINER (sw), GTK_WIDGET (view));
settings = webkit_settings_new ();
wk_settings = webkit_settings_new ();
g_object_set (G_OBJECT (settings), "user-agent", options.html_data.user_agent, NULL);
g_object_set (G_OBJECT (wk_settings), "user-agent", options.html_data.user_agent, NULL);
if (options.html_data.user_style)
{
gchar *uri = g_filename_to_uri (options.html_data.user_style, NULL, NULL);
g_object_set (G_OBJECT (settings), "user-stylesheet-uri", uri, NULL);
g_object_set (G_OBJECT (wk_settings), "user-stylesheet-uri", uri, NULL);
}
webkit_web_view_set_settings (view, settings);
webkit_web_view_set_settings (view, wk_settings);
webkit_settings_set_default_charset (settings, g_get_codeset ());
webkit_settings_set_default_charset (wk_settings, g_get_codeset ());
g_signal_connect (view, "decide-policy", G_CALLBACK (policy_cb), NULL);
g_signal_connect (view, "load-changed", G_CALLBACK (loaded_cb), NULL);
......@@ -353,14 +353,14 @@ html_create_widget (GtkWidget * dlg)
}
else
{
g_object_set (G_OBJECT(settings), "enable-caret-browsing", FALSE, NULL);
g_object_set (G_OBJECT(settings), "enable-developer-extras", FALSE, NULL);
g_object_set (G_OBJECT(settings), "enable-html5-database", FALSE, NULL);
g_object_set (G_OBJECT(settings), "enable-html5-local-storage", FALSE, NULL);
g_object_set (G_OBJECT(settings), "enable-offline-web-application-cache", FALSE, NULL);
g_object_set (G_OBJECT(settings), "enable-page-cache", FALSE, NULL);
g_object_set (G_OBJECT(settings), "enable-plugins", FALSE, NULL);
g_object_set (G_OBJECT (settings), "enable-private-browsing", TRUE, NULL);
g_object_set (G_OBJECT (wk_settings), "enable-caret-browsing", FALSE, NULL);
g_object_set (G_OBJECT (wk_settings), "enable-developer-extras", FALSE, NULL);
g_object_set (G_OBJECT (wk_settings), "enable-html5-database", FALSE, NULL);
g_object_set (G_OBJECT (wk_settings), "enable-html5-local-storage", FALSE, NULL);
g_object_set (G_OBJECT (wk_settings), "enable-offline-web-application-cache", FALSE, NULL);
g_object_set (G_OBJECT (wk_settings), "enable-page-cache", FALSE, NULL);
g_object_set (G_OBJECT (wk_settings), "enable-plugins", FALSE, NULL);
g_object_set (G_OBJECT (wk_settings), "enable-private-browsing", TRUE, NULL);
}
gtk_widget_show_all (sw);
......
......@@ -311,8 +311,7 @@ parse_desktop_file (gchar * filename)
ext_pos = g_strrstr (nm, ".desktop");
if (ext_pos)
*ext_pos = '\000';
ent->name = g_strdup (nm);
g_free (nm);
ent->name = nm;
}
/* get tooltip */
......
......@@ -436,7 +436,7 @@ add_columns ()
gtk_tree_view_column_add_attribute (column, renderer, "font", font_col);
gtk_tree_view_column_set_sort_column_id (column, i);
gtk_tree_view_column_set_resizable (column, TRUE);
if (col->type == YAD_COLUMN_TIP)
options.list_data.tooltip_column = i + 1;
break;
......@@ -757,7 +757,7 @@ get_data_as_string (GtkTreeIter *iter)
static void edit_row_cb (GtkMenuItem *item, gpointer data);
static void
double_click_cb (GtkTreeView *view, GtkTreePath *path, GtkTreeViewColumn *column, gpointer data)
double_click_cb (GtkTreeView *view, GtkTreePath *path, GtkTreeViewColumn *column, gpointer d)
{
GtkTreeModel *model;
GtkTreeIter iter;
......
......@@ -270,16 +270,11 @@ create_layout (GtkWidget *dlg)
}
/* add expander */
imw = NULL;
if (mw && options.data.expander)
{
exp = gtk_expander_new_with_mnemonic (options.data.expander);
imw = exp = gtk_expander_new_with_mnemonic (options.data.expander);
gtk_expander_set_expanded (GTK_EXPANDER (exp), FALSE);
if (mw)
{
gtk_container_add (GTK_CONTAINER (exp), mw);
imw = exp;
}
gtk_container_add (GTK_CONTAINER (exp), mw);
}
else
imw = mw;
......
......@@ -163,12 +163,13 @@ draw_page_image (GtkPrintOperation * op, GtkPrintContext * cnt, gint page, gpoin
pw = gtk_print_context_get_width (cnt);
ph = gtk_print_context_get_height (cnt);
if (options.print_data.headers)
ph -= HEADER_HEIGHT + HEADER_GAP;
/* create header */
if (options.print_data.headers)
draw_header (cnt, 1, 1);
{
ph -= HEADER_HEIGHT + HEADER_GAP;
draw_header (cnt, 1, 1);
}
/* scale image to page size */
pb = gdk_pixbuf_new_from_file (options.common_data.uri, NULL);
......@@ -425,7 +426,7 @@ yad_print_run (void)
fn = g_build_filename (g_get_user_config_dir (), "yad", NULL);
g_mkdir_with_parents (fn, 0700);
g_free (fn);
fn = g_build_filename (g_get_user_config_dir (), "yad", "print.conf", NULL);
gtk_print_settings_to_file (print_settings, fn, NULL);
gtk_page_setup_to_file (page_setup, fn, NULL);
......
......@@ -310,11 +310,10 @@ progress_create_widget (GtkWidget *dlg)
}
gtk_progress_bar_set_inverted (GTK_PROGRESS_BAR (w), p->type == YAD_PROGRESS_RTL);
if (options.common_data.vertical)
gtk_orientable_set_orientation (GTK_ORIENTABLE (w), GTK_ORIENTATION_VERTICAL);
if (options.common_data.vertical)
{
gtk_orientable_set_orientation (GTK_ORIENTABLE (w), GTK_ORIENTATION_VERTICAL);
gtk_grid_attach (GTK_GRID (table), w, i, 0, 1, 1);
gtk_widget_set_vexpand (w, TRUE);
}
......
......@@ -198,8 +198,8 @@ motion_cb (GtkWidget * w, GdkEventMotion * ev, gpointer d)
tags = gtk_text_iter_get_tags (&iter);
for (tagp = tags; tagp != NULL; tagp = tagp->next)
{
GtkTextTag *tag = tagp->data;
gint link = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (tag), "is_link"));
GtkTextTag *t = tagp->data;
gint link = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (t), "is_link"));
if (link)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment